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

Function executeWorkflowCore

apps/sim/lib/workflows/executor/execution-core.ts:313–868  ·  view source on GitHub ↗
(
  options: ExecuteWorkflowCoreOptions
)

Source from the content-addressed store, hash-verified

311}
312
313export async function executeWorkflowCore(
314 options: ExecuteWorkflowCoreOptions
315): Promise<ExecutionResult> {
316 const {
317 snapshot,
318 callbacks,
319 loggingSession,
320 skipLogCreation,
321 abortSignal,
322 includeFileBase64,
323 base64MaxBytes,
324 stopAfterBlockId,
325 runFromBlock,
326 } = options
327 const { metadata, workflow, input, workflowVariables, selectedOutputs } = snapshot
328 const { requestId, workflowId, userId, triggerType, executionId, triggerBlockId, useDraftState } =
329 metadata
330 const { onBlockStart, onBlockComplete, onStream, onChildWorkflowInstanceReady } = callbacks
331
332 const providedWorkspaceId = metadata.workspaceId
333 if (!providedWorkspaceId) {
334 throw new Error(`Execution metadata missing workspaceId for workflow ${workflowId}`)
335 }
336
337 let processedInput = input || {}
338 let deploymentVersionId: string | undefined
339 let loggingStarted = false
340 const pendingLifecycleCallbacks = new Set<Promise<void>>()
341
342 const trackLifecycleCallback = (promise: Promise<void>) => {
343 pendingLifecycleCallbacks.add(promise)
344 void promise
345 .finally(() => {
346 pendingLifecycleCallbacks.delete(promise)
347 })
348 .catch(() => {})
349 }
350
351 const waitForLifecycleCallbacks = async () => {
352 while (pendingLifecycleCallbacks.size > 0) {
353 await Promise.allSettled([...pendingLifecycleCallbacks])
354 }
355 }
356
357 try {
358 const personalEnvUserId =
359 metadata.isClientSession && metadata.sessionUserId
360 ? metadata.sessionUserId
361 : metadata.workflowUserId
362
363 if (!personalEnvUserId) {
364 throw new Error('Missing workflowUserId in execution metadata')
365 }
366
367 /**
368 * Resolves the workflow state from the override, the draft tables, or the
369 * deployed snapshot. The async load (draft/deployed) has no data dependency
370 * on the environment load, so the two are awaited concurrently below.

Callers 8

executeWorkflowFunction · 0.90
runResumeExecutionMethod · 0.90
handleExecutePostFunction · 0.90
startFunction · 0.90
executeWorkflowJobFunction · 0.90
runWorkflowExecutionFunction · 0.90

Calls 15

buildSentinelEndIdFunction · 0.90
redactObjectStringsFunction · 0.90
warmLargeValueRefsFunction · 0.90
isPlainRecordFunction · 0.90
updateWorkflowRunCountsFunction · 0.90
loadWorkflowStateFunction · 0.85
parseVariableValueByTypeFunction · 0.85

Tested by

no test coverage detected