Skip to content

Commit 586814b

Browse files
authored
worker: fix crash when a worker joins after exit
If a worker has not already joined before running to completion it will join in a SetImmediateThreadsafe which could occur after the worker has already ended by other means. Mutating a JS object at that point would fail because the isolate is already disposed. PR-URL: #56191 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
1 parent acff0ef commit 586814b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/node_worker.cc

+3
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ void Worker::JoinThread() {
449449

450450
env()->remove_sub_worker_context(this);
451451

452+
// Join may happen after the worker exits and disposes the isolate
453+
if (!env()->can_call_into_js()) return;
454+
452455
{
453456
HandleScope handle_scope(env()->isolate());
454457
Context::Scope context_scope(env()->context());

0 commit comments

Comments
 (0)