src: use maybe versions of methods

PR-URL: https://github.com/nodejs/node/pull/16005
Fixes: https://github.com/nodejs/node/issues/15864
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Tom Boutell 2017-10-06 11:30:48 -07:00 committed by Tobias Nießen
parent 6a7210edcf
commit 2e8c04b1bb
No known key found for this signature in database
GPG Key ID: 718207F8FD156B70
2 changed files with 6 additions and 5 deletions

View File

@ -496,11 +496,11 @@ bool Agent::StartIoThread(bool wait_for_connect) {
v8::Isolate* isolate = parent_env_->isolate(); v8::Isolate* isolate = parent_env_->isolate();
HandleScope handle_scope(isolate); HandleScope handle_scope(isolate);
auto context = parent_env_->context();
// Enable tracking of async stack traces // Enable tracking of async stack traces
if (!enable_async_hook_function_.IsEmpty()) { if (!enable_async_hook_function_.IsEmpty()) {
Local<Function> enable_fn = enable_async_hook_function_.Get(isolate); Local<Function> enable_fn = enable_async_hook_function_.Get(isolate);
auto context = parent_env_->context();
auto result = enable_fn->Call(context, Undefined(isolate), 0, nullptr); auto result = enable_fn->Call(context, Undefined(isolate), 0, nullptr);
if (result.IsEmpty()) { if (result.IsEmpty()) {
FatalError( FatalError(
@ -512,14 +512,15 @@ bool Agent::StartIoThread(bool wait_for_connect) {
// Send message to enable debug in workers // Send message to enable debug in workers
Local<Object> process_object = parent_env_->process_object(); Local<Object> process_object = parent_env_->process_object();
Local<Value> emit_fn = Local<Value> emit_fn =
process_object->Get(FIXED_ONE_BYTE_STRING(isolate, "emit")); process_object->Get(context, FIXED_ONE_BYTE_STRING(isolate, "emit"))
.ToLocalChecked();
// In case the thread started early during the startup // In case the thread started early during the startup
if (!emit_fn->IsFunction()) if (!emit_fn->IsFunction())
return true; return true;
Local<Object> message = Object::New(isolate); Local<Object> message = Object::New(isolate);
message->Set(FIXED_ONE_BYTE_STRING(isolate, "cmd"), message->Set(context, FIXED_ONE_BYTE_STRING(isolate, "cmd"),
FIXED_ONE_BYTE_STRING(isolate, "NODE_DEBUG_ENABLED")); FIXED_ONE_BYTE_STRING(isolate, "NODE_DEBUG_ENABLED")).FromJust();
Local<Value> argv[] = { Local<Value> argv[] = {
FIXED_ONE_BYTE_STRING(isolate, "internalMessage"), FIXED_ONE_BYTE_STRING(isolate, "internalMessage"),
message message

View File

@ -284,7 +284,7 @@ void Open(const FunctionCallbackInfo<Value>& args) {
} }
if (args.Length() > 2 && args[2]->IsBoolean()) { if (args.Length() > 2 && args[2]->IsBoolean()) {
wait_for_connect = args[2]->BooleanValue(); wait_for_connect = args[2]->BooleanValue(env->context()).FromJust();
} }
agent->StartIoThread(wait_for_connect); agent->StartIoThread(wait_for_connect);