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

Method run

apps/sim/executor/execution/engine.ts:108–193  ·  view source on GitHub ↗
(triggerBlockId?: string)

Source from the content-addressed store, hash-verified

106 }
107
108 async run(triggerBlockId?: string): Promise<ExecutionResult> {
109 const startTime = performance.now()
110 try {
111 this.initializeQueue(triggerBlockId)
112 await this.checkCancellationBackstop()
113
114 while (this.hasWork()) {
115 if (this.checkCancellation() || this.errorFlag || this.stoppedEarlyFlag) {
116 break
117 }
118 await this.processQueue()
119 }
120
121 if (!this.cancelledFlag) {
122 await this.waitForAllExecutions()
123 }
124
125 if (this.errorFlag && this.executionError && !this.responseOutputLocked) {
126 throw this.executionError
127 }
128
129 if (this.pausedBlocks.size > 0) {
130 return this.buildPausedResult(startTime)
131 }
132
133 const endTime = performance.now()
134 this.context.metadata.endTime = new Date().toISOString()
135 this.context.metadata.duration = endTime - startTime
136
137 if (this.cancelledFlag) {
138 this.finalizeIncompleteLogs()
139 return {
140 success: false,
141 output: this.finalOutput,
142 logs: this.context.blockLogs,
143 executionState: this.getSerializableExecutionState(),
144 metadata: this.context.metadata,
145 status: 'cancelled',
146 }
147 }
148
149 return {
150 success: true,
151 output: this.finalOutput,
152 logs: this.context.blockLogs,
153 executionState: this.getSerializableExecutionState(),
154 metadata: this.context.metadata,
155 }
156 } catch (error) {
157 const endTime = performance.now()
158 this.context.metadata.endTime = new Date().toISOString()
159 this.context.metadata.duration = endTime - startTime
160
161 if (this.cancelledFlag) {
162 this.finalizeIncompleteLogs()
163 return {
164 success: false,
165 output: this.finalOutput,

Callers

nothing calls this directly

Calls 13

initializeQueueMethod · 0.95
hasWorkMethod · 0.95
checkCancellationMethod · 0.95
processQueueMethod · 0.95
waitForAllExecutionsMethod · 0.95
buildPausedResultMethod · 0.95
cleanupMethod · 0.95
normalizeErrorFunction · 0.90
attachExecutionResultFunction · 0.90

Tested by

no test coverage detected