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

Function addSubflowErrorLog

apps/sim/executor/utils/subflow-utils.ts:219–279  ·  view source on GitHub ↗
(
  ctx: ExecutionContext,
  blockId: string,
  blockType: 'loop' | 'parallel',
  errorMessage: string,
  inputData: Record<string, any>,
  contextExtensions: ContextExtensions | null
)

Source from the content-addressed store, hash-verified

217 * Creates and logs an error for a subflow (loop or parallel).
218 */
219export async function addSubflowErrorLog(
220 ctx: ExecutionContext,
221 blockId: string,
222 blockType: 'loop' | 'parallel',
223 errorMessage: string,
224 inputData: Record<string, any>,
225 contextExtensions: ContextExtensions | null
226): Promise<void> {
227 const now = new Date().toISOString()
228 const execOrder = getNextExecutionOrder(ctx)
229
230 const block = ctx.workflow?.blocks?.find((b) => b.id === blockId)
231 const blockName = block?.metadata?.name || (blockType === 'loop' ? 'Loop' : 'Parallel')
232
233 const blockLog: BlockLog = {
234 blockId,
235 blockName,
236 blockType,
237 startedAt: now,
238 executionOrder: execOrder,
239 endedAt: now,
240 durationMs: 0,
241 success: false,
242 error: errorMessage,
243 input: inputData,
244 output: { error: errorMessage },
245 ...(blockType === 'loop' ? { loopId: blockId } : { parallelId: blockId }),
246 }
247 ctx.blockLogs.push(blockLog)
248
249 if (contextExtensions?.onBlockStart) {
250 try {
251 await contextExtensions.onBlockStart(blockId, blockName, blockType, execOrder)
252 } catch (error) {
253 logger.warn('Subflow error start callback failed', {
254 blockId,
255 blockType,
256 error: toError(error).message,
257 })
258 }
259 }
260
261 if (contextExtensions?.onBlockComplete) {
262 try {
263 await contextExtensions.onBlockComplete(blockId, blockName, blockType, {
264 input: inputData,
265 output: { error: errorMessage },
266 executionTime: 0,
267 startedAt: now,
268 executionOrder: execOrder,
269 endedAt: now,
270 })
271 } catch (error) {
272 logger.warn('Subflow error completion callback failed', {
273 blockId,
274 blockType,
275 error: toError(error).message,
276 })

Callers 2

addParallelErrorLogMethod · 0.90
addLoopErrorLogMethod · 0.90

Calls 6

getNextExecutionOrderFunction · 0.90
toErrorFunction · 0.90
onBlockStartMethod · 0.80
onBlockCompleteMethod · 0.80
warnMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected