From 044b153275983125d05b408451c1f54f02c7046c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Wed, 11 Jan 2023 12:15:42 +0100 Subject: [PATCH] refactor(core): Diverge syntax error handling in expressions (#5124) * :zap: Diverge syntax error handling in expressions * :pencil2: Expand comment --- packages/workflow/src/Expression.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/workflow/src/Expression.ts b/packages/workflow/src/Expression.ts index 925105a145..8817bb7da9 100644 --- a/packages/workflow/src/Expression.ts +++ b/packages/workflow/src/Expression.ts @@ -298,6 +298,17 @@ export class Expression { throw error; } } + + // Syntax errors resolve to `Error` on the frontend and `null` on the backend. + // This is a temporary divergence in evaluation behavior until we make the + // breaking change to allow syntax errors to fail executions. + if ( + typeof process === 'undefined' && + error instanceof Error && + error.name === 'SyntaxError' + ) { + throw new Error('invalid syntax'); + } } return null; }