(triggerBlockId?: string)
| 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, |
nothing calls this directly
no test coverage detected