From 162da2781f98d61f1a1cdbcccfe81f5c964f7c6b Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 17 Oct 2017 23:36:18 +0200 Subject: [PATCH] src: allow top-level calls into JSStream Allow `JSStream` instances to be used more flexibly by explicitly enabling calls that have no JS stack below them. PR-URL: https://github.com/nodejs/node/pull/16269 Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell --- src/js_stream.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/js_stream.cc b/src/js_stream.cc index b62dcf3ef5..d3d43ac6c9 100644 --- a/src/js_stream.cc +++ b/src/js_stream.cc @@ -45,6 +45,8 @@ AsyncWrap* JSStream::GetAsyncWrap() { bool JSStream::IsAlive() { + HandleScope scope(env()->isolate()); + Context::Scope context_scope(env()->context()); v8::Local fn = object()->Get(env()->isalive_string()); if (!fn->IsFunction()) return false; @@ -54,18 +56,24 @@ bool JSStream::IsAlive() { bool JSStream::IsClosing() { + HandleScope scope(env()->isolate()); + Context::Scope context_scope(env()->context()); return MakeCallback(env()->isclosing_string(), 0, nullptr) .ToLocalChecked()->IsTrue(); } int JSStream::ReadStart() { + HandleScope scope(env()->isolate()); + Context::Scope context_scope(env()->context()); return MakeCallback(env()->onreadstart_string(), 0, nullptr) .ToLocalChecked()->Int32Value(); } int JSStream::ReadStop() { + HandleScope scope(env()->isolate()); + Context::Scope context_scope(env()->context()); return MakeCallback(env()->onreadstop_string(), 0, nullptr) .ToLocalChecked()->Int32Value(); } @@ -73,6 +81,7 @@ int JSStream::ReadStop() { int JSStream::DoShutdown(ShutdownWrap* req_wrap) { HandleScope scope(env()->isolate()); + Context::Scope context_scope(env()->context()); Local argv[] = { req_wrap->object() @@ -93,6 +102,7 @@ int JSStream::DoWrite(WriteWrap* w, CHECK_EQ(send_handle, nullptr); HandleScope scope(env()->isolate()); + Context::Scope context_scope(env()->context()); Local bufs_arr = Array::New(env()->isolate(), count); Local buf;