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

src: check microtasks before running them #29434

Closed

Conversation

Copy link
Member

@codebytere codebytere commented Sep 4, 2019

Refs electron/electron#20013.

Previously, Node.js unilaterally ran microtasks on next tick; since Electron also handles microtask resolution this created an issue whereby the microtask queue would attempt to be pumped while previous tasks were still running.

To address this issue, i've changed the RunMicrotasks call to a PerformCheckpoint call, which adds checks to only run microtasks if none are in progress, and otherwise proceeds normally.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the c++ label Sep 4, 2019
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Sep 4, 2019

Copy link
Member

@bnoordhuis bnoordhuis left a comment

MicrotasksScope::PerformCheckpoint() is basically Isolate::RunMicrotasks() with a nesting guard, right? LGTM if that's the case.

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Sep 4, 2019

@codebytere
Copy link
Member Author

@codebytere codebytere commented Sep 4, 2019

@bnoordhuis yep! It just runs conditionally on:

!IsRunningMicrotasks() && !GetMicrotasksScopeDepth() && !HasMicrotasksSuppressions()

@Trott Trott added the author ready label Sep 4, 2019
Trott
Trott approved these changes Sep 4, 2019
@Trott
Copy link
Member

@Trott Trott commented Sep 4, 2019

Can't think of a simple/reliable way to test this, so LGTM without one, but commenting in case someone else has an idea.

Trott pushed a commit that referenced this issue Sep 6, 2019
PR-URL: #29434
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
@Trott
Copy link
Member

@Trott Trott commented Sep 6, 2019

Landed in 63b056d

@Trott Trott closed this Sep 6, 2019
@codebytere codebytere deleted the check-microtask-before-run branch Sep 6, 2019
nornagon added a commit to nornagon/node-1 that referenced this issue Sep 16, 2019
This is a continuation of nodejs#29434, rewriting the last remaining call to RunMicrotasks.
targos pushed a commit that referenced this issue Sep 20, 2019
PR-URL: #29434
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Trott pushed a commit that referenced this issue Sep 23, 2019
This is a continuation of #29434,
rewriting the last remaining call to RunMicrotasks.

PR-URL: #29581
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
targos pushed a commit that referenced this issue Sep 23, 2019
This is a continuation of #29434,
rewriting the last remaining call to RunMicrotasks.

PR-URL: #29581
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@BridgeAR BridgeAR mentioned this pull request Sep 24, 2019
BridgeAR pushed a commit that referenced this issue Sep 25, 2019
This is a continuation of #29434,
rewriting the last remaining call to RunMicrotasks.

PR-URL: #29581
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
codebytere added a commit to electron/electron that referenced this issue Oct 15, 2019
codebytere added a commit to electron/electron that referenced this issue Oct 15, 2019
codebytere added a commit to electron/electron that referenced this issue Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready c++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet