From 92a230667fcd3ae71759c570bcc3463dae5a976d Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Fri, 15 Dec 2023 16:27:20 +0000 Subject: [PATCH] Tell a user if their JS failed due to a timeout. --- packages/string-templates/src/helpers/javascript.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/string-templates/src/helpers/javascript.js b/packages/string-templates/src/helpers/javascript.js index c5996c25f0..d757408780 100644 --- a/packages/string-templates/src/helpers/javascript.js +++ b/packages/string-templates/src/helpers/javascript.js @@ -56,6 +56,9 @@ module.exports.processJS = (handlebars, context) => { const res = { data: runJS(js, sandboxContext) } return `{{${LITERAL_MARKER} js_result-${JSON.stringify(res)}}}` } catch (error) { + if (error.code === "ERR_SCRIPT_EXECUTION_TIMEOUT") { + return "Timed out while executing JS" + } return "Error while executing JS" } }