Unverified Commit c5de2120 authored by Anna Henningsen's avatar Anna Henningsen Committed by Myles Borins
Browse files

worker: move JoinThread() back into exit callback

de2c68c7 moved this call to
the destructor, under the assumption that that would essentially
be equivalent to running it as part of the callback since the
worker would be destroyed along with the callback.

However, the actual code in
`Environment::RunAndClearNativeImmediates()` comes with the subtlety
that testing whether a JS exception has been thrown
happens between the invocation of the callback and its destruction,
leaving a possible exception from `JoinThread()` potentially
unhandled (and unintentionally silenced through the `TryCatch`).

This affected exceptions thrown from the `'exit'` event of the
Worker, and made the `parallel/test-worker-message-type-unknown`
test flaky, as the invalid message was sometimes only received
during the Worker thread’s exit handler.

Fix this by moving the `JoinThread()` call back to where it was
before.

Refs: https://github.com/nodejs/node/pull/31386

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/31468


Reviewed-By: default avatarColin Ihrig <cjihrig@gmail.com>
Reviewed-By: default avatarGireesh Punathil <gpunathi@in.ibm.com>
parent cb16aabd
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment