Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
57 changes: 57 additions & 0 deletions apps/sim/executor/execution/executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,63 @@ describe('DAGExecutor run-from-block snapshot metadata', () => {
})
})

describe('DAGExecutor resume DAG construction', () => {
it('includes non-starter resume targets when a workflow has a disconnected starter', async () => {
const workflow: SerializedWorkflow = {
version: '1',
blocks: [
createBlock('start-t2-v2', BlockType.STARTER),
createBlock('webhook-start', 'generic_webhook'),
createBlock('hitl', BlockType.HUMAN_IN_THE_LOOP),
createBlock('generate-report', BlockType.FUNCTION),
],
connections: [
{ source: 'webhook-start', target: 'hitl', sourceHandle: 'source' },
{ source: 'hitl', target: 'generate-report', sourceHandle: 'source' },
],
loops: {},
parallels: {},
}
let capturedDag: ReturnType<DAGBuilder['build']> | undefined
const executor = new DAGExecutor({
workflow,
contextExtensions: {
resumeFromSnapshot: true,
remainingEdges: [{ source: 'hitl', target: 'generate-report', sourceHandle: 'source' }],
dagIncomingEdges: { 'start-t2-v2': [] },
snapshotState: {
blockStates: {},
executedBlocks: ['webhook-start', 'hitl'],
blockLogs: [],
decisions: { router: {}, condition: {} },
completedLoops: [],
activeExecutionPath: [],
},
},
}) as unknown as DAGExecutor & {
buildExecutionPipeline: (
context: ExecutionContext,
dag: ReturnType<DAGBuilder['build']>
) => { run: () => Promise<ExecutionResult> }
}
executor.buildExecutionPipeline = vi.fn((_context, dag) => {
capturedDag = dag
return {
run: async (): Promise<ExecutionResult> => ({
success: true,
output: { ok: true },
metadata: {},
}),
}
})

await executor.execute('wf')

expect(capturedDag?.nodes.has('generate-report')).toBe(true)
expect(capturedDag?.nodes.get('generate-report')?.incomingEdges.has('hitl')).toBe(true)
})
})

describe('DAGExecutor createExecutionContext useDraftState', () => {
function buildMetadataUseDraftState(opts: {
metadataUseDraftState?: boolean
Expand Down
1 change: 1 addition & 0 deletions apps/sim/executor/execution/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class DAGExecutor {
const dag = this.dagBuilder.build(this.workflow, {
triggerBlockId,
savedIncomingEdges,
includeAllBlocks: this.contextExtensions.resumeFromSnapshot === true,
})
const restoredClonedSubflows = this.restoreSnapshotParallelBatches(
dag,
Expand Down
Loading