File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -64,10 +64,17 @@ InternalCallbackScope::InternalCallbackScope(Environment* env,
6464 Isolate* isolate = env->isolate ();
6565
6666 HandleScope handle_scope (isolate);
67- // If you hit this assertion, you forgot to enter the v8::Context first.
68- CHECK_EQ (Environment::GetCurrent (isolate), env);
67+ Local<Context> current_context = isolate->GetCurrentContext ();
68+ // If you hit this assertion, the caller forgot to enter the right Node.js
69+ // Environment's v8::Context first.
70+ // We first check `env->context() != current_context` because the contexts
71+ // likely *are* the same, in which case we can skip the slightly more
72+ // expensive Environment::GetCurrent() call.
73+ if (UNLIKELY (env->context () != current_context)) {
74+ CHECK_EQ (Environment::GetCurrent (isolate), env);
75+ }
6976
70- env-> isolate () ->SetIdle (false );
77+ isolate->SetIdle (false );
7178
7279 env->async_hooks ()->push_async_context (
7380 async_context_.async_id , async_context_.trigger_async_id , object);
You can’t perform that action at this time.
0 commit comments