{"record":{"id":"0cb2970f2afc7403","repo":"FlowiseAI/Flowise","slug":"execution-error-name-execution-error-value","errorCode":null,"errorMessage":"${execution.error.name}: ${execution.error.value}","messagePattern":"\\$\\{execution\\.error\\.name\\}: \\$\\{execution\\.error\\.value\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/src/utils.ts","lineNumber":1712,"sourceCode":"\n            // Separate imports from the rest of the code for proper ES6 module structure\n            const codeWithImports = [\n                ...importLines,\n                `module.exports = async function() {`,\n                ...variableDeclarations,\n                ...otherLines,\n                `}()`\n            ].join('\\n')\n\n            const execution = await sbx.runCode(codeWithImports, { language: 'js' })\n\n            let output = ''\n\n            if (execution.text) output = execution.text\n            if (!execution.text && execution.logs.stdout.length) output = execution.logs.stdout.join('\\n')\n\n            if (execution.error) {\n                throw new Error(`${execution.error.name}: ${execution.error.value}`)\n            }\n\n            if (execution.logs.stderr.length) {\n                throw new Error(execution.logs.stderr.join('\\n'))\n            }\n\n            // Stream output if streaming function provided\n            if (streamOutput && output) {\n                streamOutput(output)\n            }\n\n            // Clean up sandbox\n            sbx.kill()\n\n            return parseOutput(output)\n        } catch (e) {\n            throw new Error(`Sandbox Execution Error: ${e}`)\n        }","sourceCodeStart":1694,"sourceCodeEnd":1730,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/src/utils.ts#L1694-L1730","documentation":"Thrown by the Daytona-based sandbox branch of executeJavascript after sbx.runCode returns an execution with a populated execution.error object. The error carries a name and value from the sandboxed runtime — typically a thrown JS error or a compile-time exception inside the user-supplied code string.","triggerScenarios":"User code in the tool/custom-function node throws a runtime Error (ReferenceError, TypeError, SyntaxError); a referenced variable is undefined; imported module API used incorrectly; code throws because the sandbox lacks an expected env var or file.","commonSituations":"Building a Custom Tool function with a bug; referencing a flow variable that doesn't exist; calling a dependency's API with the wrong signature inside the sandbox; SyntaxError from malformed user code that survived the import-stripping preprocessor.","solutions":["Read execution.error.name + value to identify the exact JS error (e.g. ReferenceError: foo is not defined).","Test the custom function code in isolation (node REPL or a unit test) with the same input variables.","Confirm all imported modules are in the allow-list and installed by the sandbox (librariesToInstall).","Check that flow variables passed into the sandbox match what the code expects."],"exampleFix":"// before\nif (execution.error) {\n  throw new Error(`${execution.error.name}: ${execution.error.value}`)\n}\n\n// after — include line/script context to speed debugging\nif (execution.error) {\n  throw new Error(`Sandbox code error — ${execution.error.name}: ${execution.error.value}`, )\n}\n// caller-side: wrap executeJavascript and prepend the offending code excerpt from the node config","handlingStrategy":"try-catch","validationCode":"function codeReferencesDefinedVars(code: string, sandboxKeys: string[]): string[] {\n  const missing: string[] = []\n  for (const k of sandboxKeys) if (!new RegExp(`\\\\b${k}\\\\b`).test(code)) missing.push(k)\n  return missing\n}","typeGuard":"function isExecutionError(exec: any): exec is { error: { name: string; value: string } } {\n  return exec && typeof exec === 'object' && exec.error && typeof exec.error.name === 'string'\n}","tryCatchPattern":"if (execution.error) {\n  const e = new Error(`${execution.error.name}: ${execution.error.value}`)\n  ;(e as any).sandboxError = execution.error\n  throw e\n}","preventionTips":["Lint user code (eslint) before sending it to the sandbox to catch undefined refs.","Type-check sandbox variables passed into executeJavascript against the code's expectations.","Surface execution.error.name to the UI so authors can fix the code quickly."],"tags":["sandbox","javascript-execution","custom-tool","daytona"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}