diff --git a/packages/core/src/model/nodes/CodeNode.ts b/packages/core/src/model/nodes/CodeNode.ts index 5e4811221..ef366879d 100644 --- a/packages/core/src/model/nodes/CodeNode.ts +++ b/packages/core/src/model/nodes/CodeNode.ts @@ -122,7 +122,7 @@ export class CodeNodeImpl extends NodeImpl { static getUIData(): NodeUIData { return { infoBoxBody: dedent` - Executes a piece of JavaScript code. Documentation for the inputs and outputs is available in the default code. + Executes a piece of JavaScript code. See the Rivet Documentation for more information on how to write code for the Code Node. `, infoBoxTitle: 'Code Node', contextMenuTitle: 'Code', @@ -134,6 +134,11 @@ export class CodeNodeImpl extends NodeImpl { // eslint-disable-next-line no-new-func const codeFunction = new Function('inputs', this.chartNode.data.code); const outputs = codeFunction(inputs); + + if (outputs == null || typeof outputs !== 'object') { + throw new Error('Code node must return an object with output values.'); + } + return outputs; } }