Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow Node.js to manage microtasks queue #28957

Merged
merged 2 commits into from May 3, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions shell/common/node_bindings.cc
Expand Up @@ -575,8 +575,9 @@ void NodeBindings::UvRunOnce() {
// Enter node context while dealing with uv events.
v8::Context::Scope context_scope(env->context());

// Perform microtask checkpoint after running JavaScript.
gin_helper::MicrotasksScope microtasks_scope(env->isolate());
auto old_policy = env->isolate()->GetMicrotasksPolicy();
DCHECK_EQ(v8::MicrotasksScope::GetCurrentDepth(env->isolate()), 0);
env->isolate()->SetMicrotasksPolicy(v8::MicrotasksPolicy::kExplicit);
indutny marked this conversation as resolved.
Show resolved Hide resolved

if (browser_env_ != BrowserEnvironment::kBrowser)
TRACE_EVENT_BEGIN0("devtools.timeline", "FunctionCall");
Expand All @@ -587,6 +588,8 @@ void NodeBindings::UvRunOnce() {
if (browser_env_ != BrowserEnvironment::kBrowser)
TRACE_EVENT_END0("devtools.timeline", "FunctionCall");

env->isolate()->SetMicrotasksPolicy(old_policy);

if (r == 0)
base::RunLoop().QuitWhenIdle(); // Quit from uv.

Expand Down