Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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
  • Loading branch information
airtable-keyhanvakil committed Apr 26, 2022
commit d55ddfce3be534964817d766ea59588835d3b386
2 changes: 1 addition & 1 deletion src/stream_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ void ReportWritesToJSStreamListener::OnStreamAfterReqFinished(
stream->ClearError();
}

if (req_wrap_obj->Has(env->context(), env->oncomplete_string()).FromJust())
if (req_wrap_obj->Has(env->context(), env->oncomplete_string()).FromMaybe(false))
async_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv);
}

Expand Down