Skip to content

Commit fb445b1

Browse files
authored
fix(legacy-start): fix legacy start block execution in new executor
1 parent 3bf00cb commit fb445b1

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

apps/sim/executor/handlers/trigger/trigger-handler.ts

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import { createLogger } from '@/lib/logs/console/logger'
2+
import { BlockType } from '@/executor/consts'
23
import type { BlockHandler, ExecutionContext } from '@/executor/types'
34
import type { SerializedBlock } from '@/serializer/types'
45

56
const logger = createLogger('TriggerBlockHandler')
67

7-
/**
8-
* Handler for trigger blocks (Gmail, Webhook, Schedule, etc.)
9-
* These blocks don't execute tools - they provide input data to workflows
10-
*/
118
export class TriggerBlockHandler implements BlockHandler {
129
canHandle(block: SerializedBlock): boolean {
13-
// Handle blocks that are triggers - either by category or by having triggerMode enabled
10+
if (block.metadata?.id === BlockType.STARTER) {
11+
return true
12+
}
13+
1414
const isTriggerCategory = block.metadata?.category === 'triggers'
1515

16-
// For blocks that can be both tools and triggers (like Gmail/Outlook), check if triggerMode is enabled
17-
// This would come from the serialized block config/params
1816
const hasTriggerMode = block.config?.params?.triggerMode === true
1917

2018
return isTriggerCategory || hasTriggerMode
@@ -27,6 +25,10 @@ export class TriggerBlockHandler implements BlockHandler {
2725
): Promise<any> {
2826
logger.info(`Executing trigger block: ${block.id} (Type: ${block.metadata?.id})`)
2927

28+
if (block.metadata?.id === BlockType.STARTER) {
29+
return this.executeStarterBlock(ctx, block, inputs)
30+
}
31+
3032
const existingState = ctx.blockStates.get(block.id)
3133
if (existingState?.output && Object.keys(existingState.output).length > 0) {
3234
const existingOutput = existingState.output as any
@@ -151,4 +153,31 @@ export class TriggerBlockHandler implements BlockHandler {
151153
logger.debug(`No inputs provided for trigger block ${block.id}, returning empty object`)
152154
return {}
153155
}
156+
157+
private executeStarterBlock(
158+
ctx: ExecutionContext,
159+
block: SerializedBlock,
160+
inputs: Record<string, any>
161+
): any {
162+
logger.info(`Executing starter block: ${block.id}`, {
163+
blockName: block.metadata?.name,
164+
})
165+
166+
const existingState = ctx.blockStates.get(block.id)
167+
if (existingState?.output && Object.keys(existingState.output).length > 0) {
168+
logger.debug('Returning pre-initialized starter block output', {
169+
blockId: block.id,
170+
outputKeys: Object.keys(existingState.output),
171+
})
172+
return existingState.output
173+
}
174+
175+
logger.warn('Starter block output not found in context, returning empty output', {
176+
blockId: block.id,
177+
})
178+
179+
return {
180+
input: inputs.input || '',
181+
}
182+
}
154183
}

0 commit comments

Comments
 (0)