* 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)
| 428 | * booted, on a busy machine, can have a worker still loading its modules. |
| 429 | */ |
| 430 | async destroy(closeTimeoutMs = CLOSE_TIMEOUT_MS): Promise<void> { |
| 431 | await Promise.all( |
| 432 | this.workers.map( |
| 433 | (pw) => |
| 434 | new Promise<void>((resolve) => { |
| 435 | const t = setTimeout(() => { |
| 436 | void terminateOnceStarted(pw.worker, pw.started).then(() => resolve()); |
| 437 | }, closeTimeoutMs); |
| 438 | pw.worker.once('exit', () => { |
| 439 | clearTimeout(t); |
| 440 | resolve(); |
| 441 | }); |
| 442 | pw.worker.postMessage({ type: 'close' }); |
| 443 | }) |
| 444 | ) |
| 445 | ); |
| 446 | } |
| 447 | } |
no test coverage detected