Skip to content

Commit d963142

Browse files
committed
Fix loops and parallels
1 parent 08bea87 commit d963142

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

apps/sim/executor/execution/executor.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,13 @@ export class DAGExecutor {
107107
startBlockId: string,
108108
sourceSnapshot: SerializableExecutionState
109109
): Promise<ExecutionResult> {
110-
// Pass startBlockId as trigger so DAG includes it and all downstream blocks
111-
const dag = this.dagBuilder.build(this.workflow, startBlockId)
110+
// Check if startBlockId is a regular block in the workflow
111+
// Parallel/loop containers are not in workflow.blocks, so we need to handle them differently
112+
const isRegularBlock = this.workflow.blocks.some((b) => b.id === startBlockId)
113+
114+
// For regular blocks, pass startBlockId so DAG includes it and all downstream blocks
115+
// For containers (parallel/loop), build DAG normally and let it find the trigger
116+
const dag = this.dagBuilder.build(this.workflow, isRegularBlock ? startBlockId : undefined)
112117

113118
const executedBlocks = new Set(sourceSnapshot.executedBlocks)
114119
const validation = validateRunFromBlock(startBlockId, dag, executedBlocks)
@@ -298,12 +303,19 @@ export class DAGExecutor {
298303
skipStarterBlockInit: true,
299304
})
300305
} else if (overrides?.runFromBlockContext) {
301-
// In run-from-block mode, still initialize the start block with workflow input
302-
// This ensures trigger blocks get their mock payload
303-
this.initializeStarterBlock(context, state, overrides.runFromBlockContext.startBlockId)
304-
logger.info('Run-from-block mode: initialized start block', {
305-
startBlockId: overrides.runFromBlockContext.startBlockId,
306-
})
306+
// In run-from-block mode, initialize the start block only if it's a regular block
307+
// Skip for sentinels/containers (loop/parallel) which aren't real blocks
308+
const startBlockId = overrides.runFromBlockContext.startBlockId
309+
const isRegularBlock = this.workflow.blocks.some((b) => b.id === startBlockId)
310+
311+
if (isRegularBlock) {
312+
this.initializeStarterBlock(context, state, startBlockId)
313+
logger.info('Run-from-block mode: initialized start block', { startBlockId })
314+
} else {
315+
logger.info('Run-from-block mode: skipping starter block init for container/sentinel', {
316+
startBlockId,
317+
})
318+
}
307319
} else {
308320
this.initializeStarterBlock(context, state, triggerBlockId)
309321
}

0 commit comments

Comments
 (0)