Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6187e81

Browse filesBrowse files
addaleaxtargos
authored andcommitted
src: guard slightly costly check in MakeCallback more strongly
PR-URL: #41331 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Darshan Sen <raisinten@gmail.com>
1 parent bd8b95a commit 6187e81
Copy full SHA for 6187e81

File tree

Expand file treeCollapse file tree

1 file changed

+10
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-3
lines changed
Open diff view settings
Collapse file

‎src/api/callback.cc‎

Copy file name to clipboardExpand all lines: src/api/callback.cc
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.