0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

src: move v8::HandleScope call to Emit

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: https://github.com/nodejs/node/pull/19972#issuecomment-381353894

PR-URL: https://github.com/nodejs/node/pull/20045
Reviewed-By: Yang Guo <yangguo@chromium.org>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
This commit is contained in:
Ujjwal Sharma 2018-04-15 15:29:33 +05:30
parent 76f5b3966b
commit e32eddc550
No known key found for this signature in database
GPG Key ID: 1FD3B47B83F46621
2 changed files with 1 additions and 2 deletions

View File

@ -50,7 +50,6 @@ 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());
}
@ -58,7 +57,6 @@ 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());
}

View File

@ -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));