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

timers: check can_call_into_js in Immediates #21057

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ void Environment::RunAndClearNativeImmediates() {
void Environment::CheckImmediate(uv_check_t* handle) {
Environment* env = Environment::from_immediate_check_handle(handle);

if (env->immediate_info()->count() == 0)
if (env->immediate_info()->count() == 0 || !env->can_call_into_js())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be right before the do {, because we probably want our native immediate callbacks to still be called – not all of them are calling JS, some or doing cleanup rather than something else

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that be strictly correct even if it's not calling JS? At least in relation to the main thread (and not workers), the expectation was that no user code would run after EmitExit finishes. After RunCleanup was added that's no longer the case since we run the loop one final time.

Are there are any Immediates that we truly want to have run at this point?

return;

HandleScope scope(env->isolate());
Expand All @@ -472,7 +472,7 @@ void Environment::CheckImmediate(uv_check_t* handle) {
0,
nullptr,
{0, 0}).ToLocalChecked();
} while (env->immediate_info()->has_outstanding());
} while (env->immediate_info()->has_outstanding() && env->can_call_into_js());

if (env->immediate_info()->ref_count() == 0)
env->ToggleImmediateRef(false);
Expand Down