* Starts the execution of a specific node in the build sequence. * The node will be executed if it's eligible (i.e., not completed or pending). * @param node The node to execute. * @returns A promise resolving to the result of the node execution.
(
node: BuildNode,
)
| 286 | * @returns A promise resolving to the result of the node execution. |
| 287 | */ |
| 288 | private startNodeExecution<T extends BuildHandler>( |
| 289 | node: BuildNode, |
| 290 | ): Promise<BuildResult<ExtractHandlerType<T>>> { |
| 291 | const handlerName = node.handler.name; |
| 292 | |
| 293 | // If the node is already completed, pending, or failed, skip execution |
| 294 | if ( |
| 295 | this.executionState.completed.has(handlerName) || |
| 296 | this.executionState.pending.has(handlerName) || |
| 297 | this.executionState.failed.has(handlerName) |
| 298 | ) { |
| 299 | this.logger.debug(`Node ${handlerName} already executed or in progress`); |
| 300 | return; |
| 301 | } |
| 302 | |
| 303 | // Mark the node as pending execution |
| 304 | this.executionState.pending.add(handlerName); |
| 305 | |
| 306 | // Start monitoring node execution |
| 307 | this.monitor.startNodeExecution(handlerName, this.sequence.id); |
| 308 | |
| 309 | // Execute the node handler and update the execution state accordingly |
| 310 | const executionPromise = this.invokeNodeHandler<ExtractHandlerType<T>>(node) |
| 311 | .then((result) => { |
| 312 | // Mark the node as completed and update the state |
| 313 | this.executionState.completed.add(handlerName); |
| 314 | this.executionState.pending.delete(handlerName); |
| 315 | // Store the result of the node execution |
| 316 | this.setNodeData(node.handler, result.data); |
| 317 | // End monitoring for successful execution |
| 318 | this.monitor.endNodeExecution(handlerName, this.sequence.id, true); |
| 319 | return result; |
| 320 | }) |
| 321 | .catch((error) => { |
| 322 | // Mark the node as failed in case of an error |
| 323 | this.executionState.failed.add(handlerName); |
| 324 | this.executionState.pending.delete(handlerName); |
| 325 | this.logger.error(`[Node Failed] ${handlerName}:`, error); |
| 326 | // End monitoring for failed execution |
| 327 | this.monitor.endNodeExecution( |
| 328 | handlerName, |
| 329 | this.sequence.id, |
| 330 | false, |
| 331 | error, |
| 332 | ); |
| 333 | throw error; |
| 334 | }); |
| 335 | |
| 336 | // Track the running node execution promise |
| 337 | this.runningNodes.set(handlerName, executionPromise); |
| 338 | return executionPromise; |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Executes the entire build sequence by iterating over all nodes in the sequence. |
no test coverage detected