| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Review requested:
|
Sorry, something went wrong.
|
This should probably be split into separate PRs for each module with tests added. However, I don't have time for that. I'm mostly opening this PR for visibility and discussion and hoping someone might take over if consensus is that a simple find and replace PR is not landable. |
Sorry, something went wrong.
|
this needs a Citgm run and investigate any failures deeply, I have a feeling this will be breaking. I’m +1 in principle. |
Sorry, something went wrong.
There are two problems with process.nextTick. Less severe is that it reduces performance for all async callback from native code. The more severe one is that it causes weird and unpredictable behavior when trying to interop with promises and async/await code. In particular, we have an invariant where we always emit certain events and invoke certain callbacks "asynchronously". However, that currently doesn't apply to Promise, since we "force" asynchronousity throug process.nextTick which occurs before any microtick. Hence, for any promise/micro-tick based code things actually appear to occur synchronously. Refs: nodejs#51070 PR: nodejs#51114
|
I've done what I have time with. This needs another champion to get over finish line. |
Sorry, something went wrong.
|
Hello @ronag. I have understood the issue here, but I am not sure I understand the solution to this problem. Can you point me in the right direction? I did search around and ask AI, and it seems the suggested solution is to replace process.nextTick() with queueMicrotask? |
Sorry, something went wrong.
|
Like @mcollina I'm +1 with the idea here but I definitely think this needs to be very carefully tested as this could end up breaking a LOT of code out there. I also wonder if we shouldn't give users a temporary escape hatch even after this moves forward to allow them to opt-back-in to using process.nextTick instead. That can be accomplished by setting up an internal alias method that by default is queueMicrotask but is set to process.nextTick if a CLI flag or env var is used. e.g. const internalTick = hasOption('--use-internal-nexttick') ? process.nextTick : queueMicrotask; |
Sorry, something went wrong.
|
I reviewed the files. |
Sorry, something went wrong.
|
Another option here: Perhaps instead of changing the process.nextTick callsites into queueMicrotask calls directly... perhaps process.nextTick itself could become an alias for queueMicrotask. This would help to avoid odd timing cases where Node.js changes to queueMicrotask but user code still contains to use process.nextTick |
Sorry, something went wrong.
|
Yeah, I would go for just swapping out the internals of process.nextTick to delegate to queueMicrotask and then include a flag as an escape hatch to restore the old behaviour in case it breaks anyone. They'll no doubt come to the issue tracker and complain, which will give us a signal on impact, but having an immediate fix for them with a flag should soften the blow. 😅 |
Sorry, something went wrong.
This resolve multiple timing issues related to promises and nextTick. As well as resolving zaldo in promise only code, i.e. our current best practice of using process.nextTick will always apply and work. Refs: nodejs#51156 Refs: nodejs#51156 (comment) Refs: nodejs#51114 Refs: nodejs#51070 Refs: nodejs#51156 PR-URL: nodejs#51267
Adds a new scheduling primitive to resolve zaldo when mixing traditional Node async programming with async/await and Promises. We cannot "fix" nextTick without breaking the whole ecosystem. nextTick usage should be discouraged and we should try to incrementally move to this new primitive. Refs: nodejs#51156 Refs: nodejs#51280 Refs: nodejs#51114 Refs: nodejs#51070 Refs: nodejs/undici#2497 PR-URL: nodejs#51471
| Back | FazBrowse Home | New Git URL |
There are two problems with process.nextTick.
(LOW SEVERITY) It reduces performance for all async callbacks from native code.
(HIGH SEVERITY) It causes weird and unpredictable behavior when trying to interop with promises and async/await code.
In particular, we have an invariant where we always emit events and invoke callbacks "asynchronously". However, that doesn't apply to Promise, since we "force" asynchronously through process.nextTick which occurs before any microtick. Hence, for any promise/micro-tick-based code things appear to occur synchronously. This leads to all kinds of weird and hard-to-debug bugs.
e.g.
Refs: #51070
Refs: #51156