Skip to content

Commit 6e6cbcb

Browse files
cevianclaude
andcommitted
fix: wrap workflow execution errors with node and workflow context
Errors thrown during ctx.run() now include the node type, node name, and parent workflow name so failures are traceable to their source. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 800c09f commit 6e6cbcb

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

packages/core/src/workflow.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,24 @@ function createDurableContext(config?: WorkflowRuntimeConfig): WorkflowContext {
5959
_currentNodeName = executable.name;
6060
_currentIntegrations = executable.integrations;
6161

62-
if (executable.type === "workflow" || executable.type === "agent") {
63-
// For workflows and agents, call execute directly (they handle their own DBOS registration)
64-
// This allows proper child workflow tracking
65-
return executable.execute(ctx, validated);
66-
}
62+
try {
63+
if (executable.type === "workflow" || executable.type === "agent") {
64+
// For workflows and agents, call execute directly (they handle their own DBOS registration)
65+
// This allows proper child workflow tracking
66+
return await executable.execute(ctx, validated);
67+
}
6768

68-
// For nodes, wrap execution in DBOS step for durability
69-
return DBOS.runStep(
70-
async () => executable.execute(ctx, validated),
71-
{ name: executable.name }
72-
);
69+
// For nodes, wrap execution in DBOS step for durability
70+
return await DBOS.runStep(
71+
async () => executable.execute(ctx, validated),
72+
{ name: executable.name }
73+
);
74+
} catch (err) {
75+
const msg = err instanceof Error ? err.message : String(err);
76+
throw new Error(
77+
`Error in ${executable.type} "${executable.name}" (workflow "${config?.workflowName ?? "unknown"}"): ${msg}`,
78+
);
79+
}
7380
},
7481

7582
getConnection: async (integrationId: string): Promise<ConnectionCredentials> => {

0 commit comments

Comments
 (0)