Skip to content

Commit

Permalink
src: move v8::HandleScope call to Emit
Browse files Browse the repository at this point in the history
Move v8::HandleScope call to Emit removing it from previous locations
where it was added to avoid crashing (constructor and destructor of
AsyncWrap) for a more general and fool-proof solution.

Ref: nodejs#19972 (comment)
  • Loading branch information
ryzokuken committed Apr 19, 2018
1 parent 188ed07 commit b9b7b01
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 0 additions & 2 deletions src/async_wrap-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,13 @@ inline AsyncWrap::AsyncScope::AsyncScope(AsyncWrap* wrap)
Environment* env = wrap->env();
if (env->async_hooks()->fields()[Environment::AsyncHooks::kBefore] == 0)
return;
v8::HandleScope handle_scope(env->isolate());
EmitBefore(env, wrap->get_async_id());
}

inline AsyncWrap::AsyncScope::~AsyncScope() {
Environment* env = wrap_->env();
if (env->async_hooks()->fields()[Environment::AsyncHooks::kAfter] == 0)
return;
v8::HandleScope handle_scope(env->isolate());
EmitAfter(env, wrap_->get_async_id());
}

Expand Down
1 change: 1 addition & 0 deletions src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ void Emit(Environment* env, double async_id, AsyncHooks::Fields type,
if (async_hooks->fields()[type] == 0)
return;

v8::HandleScope handle_scope(env->isolate());
Local<Value> async_id_value = Number::New(env->isolate(), async_id);
FatalTryCatch try_catch(env);
USE(fn->Call(env->context(), Undefined(env->isolate()), 1, &async_id_value));
Expand Down

0 comments on commit b9b7b01

Please sign in to comment.