diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-02-09 17:30:33 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-02-12 01:17:13 +0100 |
commit | 9e84a26cb3d390a6ce051b75c892094fff233f92 (patch) | |
tree | 8a5a7e0d7dd224cc2c227bc71509d91563d4687f | |
parent | 2c84f6e75cc513fe6e958f0489d104ee883db232 (diff) | |
download | android-node-v8-9e84a26cb3d390a6ce051b75c892094fff233f92.tar.gz android-node-v8-9e84a26cb3d390a6ce051b75c892094fff233f92.tar.bz2 android-node-v8-9e84a26cb3d390a6ce051b75c892094fff233f92.zip |
worker: keep stdio after exit
This addresses review comments from
https://github.com/nodejs/node/pull/25871.
Refs: https://github.com/nodejs/node/pull/25871
PR-URL: https://github.com/nodejs/node/pull/26017
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
-rw-r--r-- | lib/internal/worker.js | 7 | ||||
-rw-r--r-- | test/parallel/test-worker-safe-getters.js | 14 |
2 files changed, 5 insertions, 16 deletions
diff --git a/lib/internal/worker.js b/lib/internal/worker.js index 6d833bcbd2..f43a961049 100644 --- a/lib/internal/worker.js +++ b/lib/internal/worker.js @@ -171,7 +171,6 @@ class Worker extends EventEmitter { this[kPublicPort] = null; const { stdout, stderr } = this[kParentSideStdio]; - this[kParentSideStdio] = null; if (!stdout._readableState.ended) { debug(`[${threadId}] explicitly closes stdout for ${this.threadId}`); @@ -221,20 +220,14 @@ class Worker extends EventEmitter { } get stdin() { - if (this[kParentSideStdio] === null) return null; - return this[kParentSideStdio].stdin; } get stdout() { - if (this[kParentSideStdio] === null) return null; - return this[kParentSideStdio].stdout; } get stderr() { - if (this[kParentSideStdio] === null) return null; - return this[kParentSideStdio].stderr; } } diff --git a/test/parallel/test-worker-safe-getters.js b/test/parallel/test-worker-safe-getters.js index 23c8de7c7b..69856659a5 100644 --- a/test/parallel/test-worker-safe-getters.js +++ b/test/parallel/test-worker-safe-getters.js @@ -12,6 +12,8 @@ if (isMainThread) { stderr: true }); + const { stdin, stdout, stderr } = w; + w.on('exit', common.mustCall((code) => { assert.strictEqual(code, 0); @@ -21,17 +23,11 @@ if (isMainThread) { w.ref(); w.unref(); - // Although not browser specific, probably wise to - // make sure the stream getters don't throw either. - w.stdin; - w.stdout; - w.stderr; - // Sanity check. assert.strictEqual(w.threadId, -1); - assert.strictEqual(w.stdin, null); - assert.strictEqual(w.stdout, null); - assert.strictEqual(w.stderr, null); + assert.strictEqual(w.stdin, stdin); + assert.strictEqual(w.stdout, stdout); + assert.strictEqual(w.stderr, stderr); })); } else { process.exit(0); |