Skip to content

Commit b6fb7f5

Browse files
committed
ack PR comments, remove extranoeus logs
1 parent 1781279 commit b6fb7f5

File tree

6 files changed

+27
-22
lines changed

6 files changed

+27
-22
lines changed

apps/sim/app/api/workflows/[id]/execute/route.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,9 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
787787
}
788788
: {}
789789

790-
// Extract per-invocation instance ID and strip from user-visible output
791-
const childWorkflowInstanceId: string | undefined =
792-
callbackData.output?._childWorkflowInstanceId
793-
const instanceData = childWorkflowInstanceId ? { childWorkflowInstanceId } : {}
790+
const instanceData = callbackData.childWorkflowInstanceId
791+
? { childWorkflowInstanceId: callbackData.childWorkflowInstanceId }
792+
: {}
794793

795794
if (hasError) {
796795
logger.info(`[${requestId}] ✗ onBlockComplete (error) called:`, {
@@ -830,8 +829,6 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
830829
blockName,
831830
blockType,
832831
})
833-
const { _childWorkflowInstanceId: _stripped, ...strippedOutput } =
834-
callbackData.output ?? {}
835832
sendEvent({
836833
type: 'block:completed',
837834
timestamp: new Date().toISOString(),
@@ -842,7 +839,7 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
842839
blockName,
843840
blockType,
844841
input: callbackData.input,
845-
output: strippedOutput,
842+
output: callbackData.output,
846843
durationMs: callbackData.executionTime || 0,
847844
startedAt: callbackData.startedAt,
848845
executionOrder: callbackData.executionOrder,

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ export function getBlockColor(blockType: string): string {
101101
}
102102

103103
/**
104-
* Checks if a block type is a child workflow node
104+
* Checks if a block type is a workflow-calling block (calls a child workflow).
105+
* Covers both `workflow` (new) and `workflow_input` (legacy) block variants —
106+
* both are handled by WorkflowBlockHandler and emit child workflow events.
105107
*/
106108
export function isWorkflowBlockType(blockType: string): boolean {
107109
const t = blockType?.toLowerCase()

apps/sim/executor/execution/block-executor.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ export class BlockExecutor {
166166
this.state.setBlockOutput(node.id, normalizedOutput, duration)
167167

168168
if (!isSentinel && blockLog) {
169+
const childWorkflowInstanceId = normalizedOutput._childWorkflowInstanceId as
170+
| string
171+
| undefined
169172
const displayOutput = filterOutputForLog(block.metadata?.id || '', normalizedOutput, {
170173
block,
171174
})
@@ -178,7 +181,8 @@ export class BlockExecutor {
178181
duration,
179182
blockLog.startedAt,
180183
blockLog.executionOrder,
181-
blockLog.endedAt
184+
blockLog.endedAt,
185+
childWorkflowInstanceId
182186
)
183187
}
184188

@@ -249,9 +253,6 @@ export class BlockExecutor {
249253
if (error.childWorkflowSnapshotId) {
250254
errorOutput.childWorkflowSnapshotId = error.childWorkflowSnapshotId
251255
}
252-
if (error.childWorkflowInstanceId) {
253-
errorOutput._childWorkflowInstanceId = error.childWorkflowInstanceId
254-
}
255256
}
256257

257258
this.state.setBlockOutput(node.id, errorOutput, duration)
@@ -279,6 +280,9 @@ export class BlockExecutor {
279280
)
280281

281282
if (!isSentinel && blockLog) {
283+
const childWorkflowInstanceId = ChildWorkflowError.isChildWorkflowError(error)
284+
? error.childWorkflowInstanceId
285+
: undefined
282286
const displayOutput = filterOutputForLog(block.metadata?.id || '', errorOutput, { block })
283287
this.callOnBlockComplete(
284288
ctx,
@@ -289,7 +293,8 @@ export class BlockExecutor {
289293
duration,
290294
blockLog.startedAt,
291295
blockLog.executionOrder,
292-
blockLog.endedAt
296+
blockLog.endedAt,
297+
childWorkflowInstanceId
293298
)
294299
}
295300

@@ -458,7 +463,8 @@ export class BlockExecutor {
458463
duration: number,
459464
startedAt: string,
460465
executionOrder: number,
461-
endedAt: string
466+
endedAt: string,
467+
childWorkflowInstanceId?: string
462468
): void {
463469
const blockId = node.metadata?.originalBlockId ?? node.id
464470
const blockName = block.metadata?.name ?? blockId
@@ -478,6 +484,7 @@ export class BlockExecutor {
478484
startedAt,
479485
executionOrder,
480486
endedAt,
487+
childWorkflowInstanceId,
481488
},
482489
iterationContext,
483490
ctx.childWorkflowContext

apps/sim/executor/execution/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ export interface ContextExtensions {
132132
startedAt: string
133133
executionOrder: number
134134
endedAt: string
135+
/** Per-invocation unique ID linking this workflow block execution to its child block events. */
136+
childWorkflowInstanceId?: string
135137
},
136138
iterationContext?: IterationContext,
137139
childWorkflowContext?: ChildWorkflowContext

apps/sim/lib/execution/isolated-vm.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,6 @@ function cleanupWorker(workerId: number) {
619619
workerInfo.activeExecutions = 0
620620

621621
workers.delete(workerId)
622-
logger.info('Worker removed from pool', { workerId, poolSize: workers.size })
623622
}
624623

625624
function resetWorkerIdleTimeout(workerId: number) {
@@ -635,7 +634,6 @@ function resetWorkerIdleTimeout(workerId: number) {
635634
workerInfo.idleTimeout = setTimeout(() => {
636635
const w = workers.get(workerId)
637636
if (w && w.activeExecutions === 0) {
638-
logger.info('Cleaning up idle worker', { workerId })
639637
cleanupWorker(workerId)
640638
}
641639
}, WORKER_IDLE_TIMEOUT_MS)

apps/sim/lib/workflows/executor/execution-events.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ export function createSSECallbacks(options: SSECallbackOptions) {
271271
startedAt: string
272272
executionOrder: number
273273
endedAt: string
274+
childWorkflowInstanceId?: string
274275
},
275276
iterationContext?: IterationContext,
276277
childWorkflowContext?: ChildWorkflowContext
@@ -291,10 +292,9 @@ export function createSSECallbacks(options: SSECallbackOptions) {
291292
}
292293
: {}
293294

294-
// Extract per-invocation instance ID and strip from user-visible output
295-
const childWorkflowInstanceId: string | undefined =
296-
callbackData.output?._childWorkflowInstanceId
297-
const instanceData = childWorkflowInstanceId ? { childWorkflowInstanceId } : {}
295+
const instanceData = callbackData.childWorkflowInstanceId
296+
? { childWorkflowInstanceId: callbackData.childWorkflowInstanceId }
297+
: {}
298298

299299
if (hasError) {
300300
sendEvent({
@@ -318,7 +318,6 @@ export function createSSECallbacks(options: SSECallbackOptions) {
318318
},
319319
})
320320
} else {
321-
const { _childWorkflowInstanceId: _stripped, ...strippedOutput } = callbackData.output ?? {}
322321
sendEvent({
323322
type: 'block:completed',
324323
timestamp: new Date().toISOString(),
@@ -329,7 +328,7 @@ export function createSSECallbacks(options: SSECallbackOptions) {
329328
blockName,
330329
blockType,
331330
input: callbackData.input,
332-
output: strippedOutput,
331+
output: callbackData.output,
333332
durationMs: callbackData.executionTime || 0,
334333
startedAt: callbackData.startedAt,
335334
executionOrder: callbackData.executionOrder,

0 commit comments

Comments
 (0)