()
| 498 | } |
| 499 | |
| 500 | async run() { |
| 501 | await this._ensureInitialized() |
| 502 | recorder.startUnlessRunning() |
| 503 | event.dispatcher.emit(event.workers.before) |
| 504 | store.workerMode = true |
| 505 | process.env.RUNS_WITH_WORKERS = 'true' |
| 506 | |
| 507 | // Create workers and set up message handlers immediately (not in recorder queue) |
| 508 | // This prevents a race condition where workers start sending messages before handlers are attached |
| 509 | const workerThreads = [] |
| 510 | for (const worker of this.workers) { |
| 511 | const workerThread = createWorker(worker, this.isPoolMode) |
| 512 | this._listenWorkerEvents(workerThread) |
| 513 | workerThreads.push(workerThread) |
| 514 | } |
| 515 | |
| 516 | recorder.add('workers started', () => { |
| 517 | // Workers are already running, this is just a placeholder step |
| 518 | }) |
| 519 | |
| 520 | return new Promise(resolve => { |
| 521 | this.on('end', () => { |
| 522 | resolve() |
| 523 | }) |
| 524 | }) |
| 525 | } |
| 526 | |
| 527 | /** |
| 528 | * @returns {Array<WorkerObject>} |
nothing calls this directly
no test coverage detected