Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeyhan Vakil <60900335+airtable-keyhanvakil@users.noreply.github.com>2022-05-07 01:01:04 +0300
committerRafaelGSS <rafael.nunu@hotmail.com>2022-05-10 15:13:19 +0300
commit5470578008023f426f0ace07a192c81256c889d9 (patch)
tree7a65aa01e1f0476dfbb98a85256d3fc8215cbe63 /src/stream_base.cc
parent7cac7bb806d73aafba106fd300d1f4d5849f039a (diff)
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: https://github.com/nodejs/node/issues/38418 PR-URL: https://github.com/nodejs/node/pull/42874 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'src/stream_base.cc')
-rw-r--r--src/stream_base.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/stream_base.cc b/src/stream_base.cc
index a47fad97035..2b3fbe38ff2 100644
--- a/src/stream_base.cc
+++ b/src/stream_base.cc
@@ -601,6 +601,7 @@ void ReportWritesToJSStreamListener::OnStreamAfterReqFinished(
StreamReq* req_wrap, int status) {
StreamBase* stream = static_cast<StreamBase*>(stream_);
Environment* env = stream->stream_env();
+ if (env->is_stopping()) return;
AsyncWrap* async_wrap = req_wrap->GetAsyncWrap();
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());