* 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)
| 355 | * booted, on a busy machine, can have a worker still loading its modules. |
| 356 | */ |
| 357 | async destroy(closeTimeoutMs = CLOSE_TIMEOUT_MS): Promise<void> { |
| 358 | await Promise.all( |
| 359 | this.workers.map( |
| 360 | (pw) => |
| 361 | new Promise<void>((resolve) => { |
| 362 | const t = setTimeout(() => { |
| 363 | void terminateOnceStarted(pw.worker, pw.started).then(() => resolve()); |
| 364 | }, closeTimeoutMs); |
| 365 | pw.worker.once('exit', () => { |
| 366 | clearTimeout(t); |
| 367 | resolve(); |
| 368 | }); |
| 369 | pw.worker.postMessage({ type: 'close' }); |
| 370 | }) |
| 371 | ) |
| 372 | ); |
| 373 | } |
| 374 | } |
no test coverage detected