diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-09-07 21:56:24 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-09-09 22:21:37 +0200 |
commit | 2833a0d8b7c3f0f5e80059d7a428328c96cbee54 (patch) | |
tree | c37a4acaa6a4db4a86c7e29dc2648216d9d77c1b /lib | |
parent | d7c5ffc7a423f0df3f289cbc815510e050282d43 (diff) | |
download | android-node-v8-2833a0d8b7c3f0f5e80059d7a428328c96cbee54.tar.gz android-node-v8-2833a0d8b7c3f0f5e80059d7a428328c96cbee54.tar.bz2 android-node-v8-2833a0d8b7c3f0f5e80059d7a428328c96cbee54.zip |
worker: make terminate() resolve for unref’ed Workers
Once `worker.terminate()` is called, the Worker instance will be
destroyed as soon as possible anyway, so in order to make
the Promise returned by `worker.terminate()` resolve always,
it should be okay to just call `.ref()` on it and keep the main
event loop alive temporarily.
PR-URL: https://github.com/nodejs/node/pull/29484
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/worker.js | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/internal/worker.js b/lib/internal/worker.js index 3cd5472b93..df0646ff4f 100644 --- a/lib/internal/worker.js +++ b/lib/internal/worker.js @@ -226,6 +226,8 @@ class Worker extends EventEmitter { terminate(callback) { debug(`[${threadId}] terminates Worker with ID ${this.threadId}`); + this.ref(); + if (typeof callback === 'function') { process.emitWarning( 'Passing a callback to worker.terminate() is deprecated. ' + |