Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
address comments
  • Loading branch information
icecrasher321 committed Apr 3, 2026
commit 33aa581351d26ca0e85de825534f992c37a742a7
44 changes: 43 additions & 1 deletion apps/sim/executor/execution/engine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ describe('ExecutionEngine', () => {
return {
nodeId,
output: { data: { fast: true }, status: 200, headers: {} },
isFinalOutput: false,
isFinalOutput: true,
}
}
if (nodeId === 'slow-work') {
Expand Down Expand Up @@ -1204,6 +1204,48 @@ describe('ExecutionEngine', () => {
expect(result.success).toBe(true)
expect(result.output).toEqual({ data: { response: true }, status: 200, headers: {} })
})

it('should honor locked Response output even when a parallel node throws an error', async () => {
const startNode = createMockNode('start', 'starter')
const responseNode = createMockNode('response', 'response')
const errorNode = createMockNode('error-node', 'function')

startNode.outgoingEdges.set('edge1', { target: 'response' })
startNode.outgoingEdges.set('edge2', { target: 'error-node' })

const dag = createMockDAG([startNode, responseNode, errorNode])
const context = createMockContext()
const edgeManager = createMockEdgeManager((node) => {
if (node.id === 'start') return ['response', 'error-node']
return []
})

const nodeOrchestrator = {
executionCount: 0,
executeNode: vi.fn().mockImplementation(async (_ctx: ExecutionContext, nodeId: string) => {
nodeOrchestrator.executionCount++
if (nodeId === 'response') {
return {
nodeId,
output: { data: { ok: true }, status: 200, headers: {} },
isFinalOutput: true,
}
}
if (nodeId === 'error-node') {
await new Promise((resolve) => setTimeout(resolve, 1))
throw new Error('Parallel branch failed')
}
return { nodeId, output: {}, isFinalOutput: false }
}),
handleNodeCompletion: vi.fn(),
} as unknown as MockNodeOrchestrator

const engine = new ExecutionEngine(context, dag, edgeManager, nodeOrchestrator)
const result = await engine.run('start')

expect(result.success).toBe(true)
expect(result.output).toEqual({ data: { ok: true }, status: 200, headers: {} })
})
})

describe('Cancellation flag behavior', () => {
Expand Down
5 changes: 3 additions & 2 deletions apps/sim/executor/execution/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ export class ExecutionEngine {
await this.waitForAllExecutions()
}

// Rethrow the captured error so it's handled by the catch block
if (this.errorFlag && this.executionError) {
if (this.errorFlag && this.executionError && !this.responseOutputLocked) {
throw this.executionError
}

Expand Down Expand Up @@ -401,6 +400,8 @@ export class ExecutionEngine {
}

if (this.stoppedEarlyFlag && this.responseOutputLocked) {
// Workflow already ended via Response block. Skip state persistence (setBlockOutput),
// parallel/loop scope tracking, and edge propagation — no downstream blocks will run.
return
}
Comment thread
icecrasher321 marked this conversation as resolved.

Expand Down
Loading