| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bd8b95a commit 6187e81
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,10 +64,17 @@ InternalCallbackScope::InternalCallbackScope(Environment* env, | |||
| 64 | 64 | Isolate* isolate = env->isolate(); | |
| 65 | 65 | ||
| 66 | 66 | 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 | + } | ||
| 69 | 76 | ||
| 70 | - env->isolate()->SetIdle(false); | ||
| 77 | + isolate->SetIdle(false); | ||
| 71 | 78 | ||
| 72 | 79 | env->async_hooks()->push_async_context( | |
| 73 | 80 | async_context_.async_id, async_context_.trigger_async_id, object); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments