* Ask every worker to close; each collects garbage and exits by itself (see * worker-teardown.ts). One that hasn't by `closeTimeoutMs` is terminated — * but never while it is still starting up: a pool torn down soon after it * booted, on a busy machine, can have a worker still loading its m
(closeTimeoutMs = CLOSE_TIMEOUT_MS)
| 465 | * booted, on a busy machine, can have a worker still loading its modules. |
| 466 | */ |
| 467 | async destroy(closeTimeoutMs = CLOSE_TIMEOUT_MS): Promise<void> { |
| 468 | await Promise.all( |
| 469 | this.workers.map( |
| 470 | (pw) => |
| 471 | new Promise<void>((resolve) => { |
| 472 | const t = setTimeout(() => { |
| 473 | void terminateOnceStarted(pw.worker, pw.started).then(() => resolve()); |
| 474 | }, closeTimeoutMs); |
| 475 | pw.worker.once('exit', () => { |
| 476 | clearTimeout(t); |
| 477 | resolve(); |
| 478 | }); |
| 479 | pw.worker.postMessage({ type: 'close' }); |
| 480 | }) |
| 481 | ) |
| 482 | ); |
| 483 | } |
| 484 | } |
no test coverage detected