Uh oh!
There was an error while loading. Please reload this page.
promises: refactor rejection handling - #18207
Conversation
CI: https://ci.nodejs.org/job/node-test-pull-request/12580/ Edit: weird failures in CitGM. Investigating... |
apapirovski
commented
Jan 17, 2018
CitGM failures unrelated to this PR but clearly something landed in the last 24 hours that completely destroyed CitGM. |
I'll need a few days to digest this and run through the edge cases we had when we specified the hooks. Pinging (no pressure to participate!) relevant parties @petkaantonov@addaleax@domenic |
Just to distill what's going on in the current loop, here's an outline:
|
There was a problem hiding this comment.
I’m not sure, but, common.mustCall()? ;)
There was a problem hiding this comment.
Since it checks at exit, this would just keep looping forever until timeout is hit.
benjamingr
left a comment
There was a problem hiding this comment.
After reading the code and testing it - I like the behavior and changes. LGTM.
Remove the unnecessary microTasksTickObject for scheduling microtasks and instead use TickInfo to keep track of whether promise rejections exist that need to be emitted. Consequently allow the microtasks to execute on average fewer times, in more predictable manner than previously. Simplify unhandled & handled rejection tracking to do more in C++ to avoid needing to expose additional info in JS. When new unhandledRejections are emitted within an unhandledRejection handler, allow the event loop to proceed first instead. This means that if the end-user code handles all promise rejections on nextTick, rejections within unhandledRejection now won't spiral into an infinite loop.
0413ebb to
21a2220CompareBridgeAR
commented
Jan 19, 2018
New CI due to some changed code (If I am not mistaken) https://ci.nodejs.org/job/node-test-pull-request/12619/ |
@BridgeAR It was just rebased to make it possible to run the CitGM. But no harm in extra CI :) |
apapirovski
commented
Jan 21, 2018
Landed in d62566e |
Remove the unnecessary microTasksTickObject for scheduling microtasks and instead use TickInfo to keep track of whether promise rejections exist that need to be emitted. Consequently allow the microtasks to execute on average fewer times, in more predictable manner than previously. Simplify unhandled & handled rejection tracking to do more in C++ to avoid needing to expose additional info in JS. When new unhandledRejections are emitted within an unhandledRejection handler, allow the event loop to proceed first instead. This means that if the end-user code handles all promise rejections on nextTick, rejections within unhandledRejection now won't spiral into an infinite loop. PR-URL: #18207Fixes: #17913 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
MylesBorins
commented
Feb 20, 2018
This does not land cleanly on v9.x, should we backport? |
apapirovski
commented
Feb 20, 2018
@MylesBorins v9.x might be missing some preceding commits, I think. I'll have time to look into it at the end of the week or the weekend, swamped with a move right now. Sorry. |
addaleax
commented
Feb 27, 2018
This seem to apply cleanly on v9.x now, I’m removing the label. |
Remove the unnecessary microTasksTickObject for scheduling microtasks and instead use TickInfo to keep track of whether promise rejections exist that need to be emitted. Consequently allow the microtasks to execute on average fewer times, in more predictable manner than previously. Simplify unhandled & handled rejection tracking to do more in C++ to avoid needing to expose additional info in JS. When new unhandledRejections are emitted within an unhandledRejection handler, allow the event loop to proceed first instead. This means that if the end-user code handles all promise rejections on nextTick, rejections within unhandledRejection now won't spiral into an infinite loop. PR-URL: nodejs#18207Fixes: nodejs#17913 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Remove the unnecessary microTasksTickObject for scheduling microtasks and instead use TickInfo to keep track of whether promise rejections exist that need to be emitted. Consequently allow the microtasks to execute on average fewer times, in more predictable manner than previously. Simplify unhandled & handled rejection tracking to do more in C++ to avoid needing to expose additional info in JS. When new unhandledRejections are emitted within an unhandledRejection handler, allow the event loop to proceed first instead. This means that if the end-user code handles all promise rejections on nextTick, rejections within unhandledRejection now won't spiral into an infinite loop. PR-URL: nodejs#18207Fixes: nodejs#17913 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
codebytere
commented
Aug 2, 2018
@apapirovski this doesn't land cleanly on |
apapirovski
commented
Aug 2, 2018
@codebytere Yeah, probably wouldn't hurt. I have a backlog of things I'm supposed to backport anyway. I'll do them all this weekend. |
Remove the unnecessary microTasksTickObject for scheduling microtasks and instead use TickInfo to keep track of whether promise rejections exist that need to be emitted. Consequently allow the microtasks to execute on average fewer times, in more predictable manner than previously.
Simplify unhandled & handled rejection tracking to do more in C++ to avoid needing to expose additional info in JS. Unite emitting unhandledRejection and rejectionHandled into a single function: emitPromiseRejectionWarnings, which runs after all nextTicks have executed.
When new unhandledRejections are emitted within an unhandledRejection handler, allow the event loop to proceed first instead. This means that if the end-user code handles all promise rejections on nextTick, rejections within unhandledRejection now won't spiral into an infinite loop.
On the whole, this should hopefully make reasoning about nextTick, promises and promise rejections a whole lot simpler.
Fixes: #17913
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
process, promises, src