Skip to content

Commit ce6ca47

Browse files
worker: fix stream racing with terminate
`OnStreamAfterReqFinished` uses `v8::Object::Has` to check if it needs to call `oncomplete`. `v8::Object::Has` needs to execute Javascript. However when worker threads are involved, `OnStreamAfterReqFinished` may be called after the worker thread termination has begun via `worker.terminate()`. This makes `v8::Object::Has` return `Nothing`, which triggers an assert. This diff fixes the issue by simply defaulting us to `false` in the case where `Nothing` is returned. This is sound because we can't execute `oncomplete` anyway as the isolate is terminating. Fixes: #38418
1 parent 4f9bc41 commit ce6ca47

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/stream_base.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ void ReportWritesToJSStreamListener::OnStreamAfterReqFinished(
619619
stream->ClearError();
620620
}
621621

622-
if (req_wrap_obj->Has(env->context(), env->oncomplete_string()).FromJust())
622+
if (req_wrap_obj->Has(env->context(), env->oncomplete_string())
623+
.FromMaybe(false))
623624
async_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv);
624625
}
625626

0 commit comments

Comments
 (0)