Skip to main content

runNode

workflow.runNode() executes a normal node. It is responsible for interrupt checking, node start/end hooks, execution information logging, and error wrapping.

Signature

workflow.runNode<Input, Output>(
node: NodeDefinition<Input, Output>,
input: Input,
context: NodeContext,
): Promise<Output>

Parameter

ParameterTypeDescription
nodeNodeDefinition<Input, Output>The node object to be executed, usually from a node factory.
inputInputNode input.
contextNodeContextruntime context for hooks, provider, KV, files, abortSignal.

NodeDefinition

FieldDescription
nameThe node name. Required.
standardNameStandard node type name, such as input, llm, output.
metadataStructure diagram and UI meta information.
runThe node executes the function, receiving input and NodeContext. Required.

Execution process

StepsDescription
1. Check for interruptionsIf context.abortSignal is interrupted, throw execution_aborted.
2. Send Start EventThe trigger node starts a hook and records the executionId, nodeName, metadata, and startedAt.
3. Execution nodeCall node.run(input, context).
4. Send Completion EventRecord the output, duration, and executionInfo, and trigger the completion of the hook.
5. Wrong packagingConvert to WorkflowError on failure and write report.

Return value

ReturnTypeDescription
Node outputPromise<Output>Returns the result of node.run on success.

Error

SituationError TypeDescription
Break before or during executionexecution_abortedFrom context.abortSignal.
Node throw errornode_executionUnknown errors are wrapped as WorkflowError; existing WorkflowError is preserved and the context is supplemented.

Example

const parsed = await workflow.runNode(inputNode, input, context);
const answer = await workflow.runNode(llmNode, parsed, context);
const output = await workflow.runNode(outputNode, answer, context);

The difference from runStreamNode

MethodNode typeReturn
runNodeNodeDefinitionSingle Output.
runStreamNodeStreamNodeDefinition{ chunks, output }.