Skip to content
This repository was archived by the owner on Aug 31, 2018. It is now read-only.

Commit 6cbef5a

Browse files
committedDec 7, 2017
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: nodejs/node#16269 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 73a252e commit 6cbef5a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 

‎src/js_stream.cc

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ AsyncWrap* JSStream::GetAsyncWrap() {
4545

4646

4747
bool JSStream::IsAlive() {
48+
HandleScope scope(env()->isolate());
49+
Context::Scope context_scope(env()->context());
4850
v8::Local<v8::Value> fn = object()->Get(env()->isalive_string());
4951
if (!fn->IsFunction())
5052
return false;
@@ -54,25 +56,32 @@ bool JSStream::IsAlive() {
5456

5557

5658
bool JSStream::IsClosing() {
59+
HandleScope scope(env()->isolate());
60+
Context::Scope context_scope(env()->context());
5761
return MakeCallback(env()->isclosing_string(), 0, nullptr)
5862
.ToLocalChecked()->IsTrue();
5963
}
6064

6165

6266
int JSStream::ReadStart() {
67+
HandleScope scope(env()->isolate());
68+
Context::Scope context_scope(env()->context());
6369
return MakeCallback(env()->onreadstart_string(), 0, nullptr)
6470
.ToLocalChecked()->Int32Value();
6571
}
6672

6773

6874
int JSStream::ReadStop() {
75+
HandleScope scope(env()->isolate());
76+
Context::Scope context_scope(env()->context());
6977
return MakeCallback(env()->onreadstop_string(), 0, nullptr)
7078
.ToLocalChecked()->Int32Value();
7179
}
7280

7381

7482
int JSStream::DoShutdown(ShutdownWrap* req_wrap) {
7583
HandleScope scope(env()->isolate());
84+
Context::Scope context_scope(env()->context());
7685

7786
Local<Value> argv[] = {
7887
req_wrap->object()
@@ -93,6 +102,7 @@ int JSStream::DoWrite(WriteWrap* w,
93102
CHECK_EQ(send_handle, nullptr);
94103

95104
HandleScope scope(env()->isolate());
105+
Context::Scope context_scope(env()->context());
96106

97107
Local<Array> bufs_arr = Array::New(env()->isolate(), count);
98108
Local<Object> buf;

0 commit comments

Comments
 (0)
This repository has been archived.