worker: do not throw on property access or postMessage after termination#25871
worker: do not throw on property access or postMessage after termination#25871chjj wants to merge 2 commits intonodejs:masterfrom
Conversation
|
CI: https://ci.nodejs.org/job/node-test-pull-request/20512/ /cc @nodejs/workers |
I don't know, it seems better to me if they continue to exist, but are closed. EDIT: sorry, ignore this. I thought this was the cluster Worker, but its not. I have no opinion on WebWorkers. The API is supposed to be standardized, does the standard not address this? |
|
I edited my comment above, but then remembered edits don't cause notifications. See ----^ |
|
@sam-github, I'm not sure what the standard says, but chromium 71 fails silently when calling
|
|
Mmm, will modify to make the linter happy. |
|
Should be fixed. I can squash and push again if that's preferred. |
|
|
||
| // Sanity check. | ||
| assert.strictEqual(w.threadId, -1); | ||
| assert.strictEqual(w.stdin, null); |
There was a problem hiding this comment.
Nit: this also checks that w.stdin does not throw. Can the one above be removed?
|
@chjj I think @sam-github’s suggestion for stdio was to make the getters not throw by removing the |
|
Resume CI: https://ci.nodejs.org/job/node-test-pull-request/20625/ If this isn’t addressed in this PR, I think I’d like to land this and then apply @sam-github’s suggestion and make sure one PR doesn’t get released without the other. |
PR-URL: nodejs#25871 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: James M Snell <jasnell@gmail.com>
This addresses review comments from nodejs#25871. Refs: nodejs#25871
PR-URL: #25871 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: James M Snell <jasnell@gmail.com>
Worker#postMessage,Worker#stdin,Worker#stdout, andWorker#stderrcurrently throw if called/accessed after a worker is terminated.postMessagesilently fails in the browser after termination. It also seems cleaner if the stdio streams are set tonullafter termination. This PR implements that behavior.