MCPcopy Index your code
hub / github.com/simstudioai/sim / onBlockComplete

Function onBlockComplete

apps/sim/lib/workflows/executor/execution-events.ts:324–406  ·  view source on GitHub ↗
(
    blockId: string,
    blockName: string,
    blockType: string,
    callbackData: {
      input?: unknown
      output: any
      executionTime: number
      startedAt: string
      executionOrder: number
      endedAt: string
      childWorkflowInstanceId?: string
    },
    iterationContext?: IterationContext,
    childWorkflowContext?: ChildWorkflowContext
  )

Source from the content-addressed store, hash-verified

322 }
323
324 const onBlockComplete = async (
325 blockId: string,
326 blockName: string,
327 blockType: string,
328 callbackData: {
329 input?: unknown
330 output: any
331 executionTime: number
332 startedAt: string
333 executionOrder: number
334 endedAt: string
335 childWorkflowInstanceId?: string
336 },
337 iterationContext?: IterationContext,
338 childWorkflowContext?: ChildWorkflowContext
339 ) => {
340 const hasError = callbackData.output?.error
341 const iterationData = iterationContext
342 ? {
343 iterationCurrent: iterationContext.iterationCurrent,
344 iterationTotal: iterationContext.iterationTotal,
345 iterationType: iterationContext.iterationType,
346 iterationContainerId: iterationContext.iterationContainerId,
347 ...(iterationContext.parentIterations?.length && {
348 parentIterations: iterationContext.parentIterations,
349 }),
350 }
351 : {}
352 const childWorkflowData = childWorkflowContext
353 ? {
354 childWorkflowBlockId: childWorkflowContext.parentBlockId,
355 childWorkflowName: childWorkflowContext.workflowName,
356 }
357 : {}
358
359 const instanceData = callbackData.childWorkflowInstanceId
360 ? { childWorkflowInstanceId: callbackData.childWorkflowInstanceId }
361 : {}
362
363 if (hasError) {
364 await sendBufferedEvent({
365 type: 'block:error',
366 timestamp: new Date().toISOString(),
367 executionId,
368 workflowId,
369 data: {
370 blockId,
371 blockName,
372 blockType,
373 input: callbackData.input,
374 error: callbackData.output.error,
375 durationMs: callbackData.executionTime || 0,
376 startedAt: callbackData.startedAt,
377 executionOrder: callbackData.executionOrder,
378 endedAt: callbackData.endedAt,
379 ...iterationData,
380 ...childWorkflowData,
381 ...instanceData,

Callers 2

wrappedOnBlockCompleteFunction · 0.70
streaming.test.tsFile · 0.50

Calls 1

sendBufferedEventFunction · 0.85

Tested by

no test coverage detected