-
Notifications
You must be signed in to change notification settings - Fork 7.3k
test: microtask-queue-run(-domain) should be made non-flaky #25607
Comments
/cc @joyent/node-collaborators |
It looks like the callbacks are executing in a different order sometimes.
This fails sometimes because the callback on line (C) fires before the callback on line (B). This looks to be the same thing that causes the Interestingly, this variant does not fail for me:
|
Looking at the API doc it seems like This test also doesn't fail for me:
|
Finally, this test does fail sometimes:
So it looks like |
Looks like I got the ordering slightly wrong. The
Also, note that |
So, I'm not 100% sure of the intention of the original test, but it looks like it would be appropriate to change the |
This test seems to fail quite regularly in our internal IBM builds, @tunniclm you may be able to validate your changes there. |
Whenever a timer of a specific delay creates a new timer with the same delay we currently end up processing the new timer immediately instead of scheduling the timer to run in the future. This commit basically identifies the situation, halts processing the current timer chain and reschedules the timer chain appropriately in the future. Fixes nodejs#25607
Whenever a timer of a specific delay creates a new timer with the same delay we currently end up processing the new timer immediately instead of scheduling the timer to run in the future. This commit basically identifies the situation, halts processing the current timer chain and reschedules the timer chain appropriately in the future. Fixes nodejs#25607
@tunniclm @mhdawson Although I'm not the original author of the test, its intention seems to make sure that microtasks run at the appropriate time compared to timers' and The reason why this test is flaky is described in one comment of the PR that fixes it. |
Whenever a timer with a specific timeout value creates a new timer with the same timeout, the newly added timer might be processed immediately in the same tick of the event loop instead of during the next tick of the event loop at the earliest. Fixes nodejs#25607
@misterdjules I looked through that thread on Friday (and the original commit that added the test) as I started to get back to looking at issues (I was unavailable for a few weeks). From that, my understanding is that the tests are there to ensure that the V8 microtask queue used to process the "built-in" Promises were being executed at the right time in comparison to setImmediate(), setTimeout() and process.nextTick(). Particularly when there were nested callbacks. What I found in my exploration of nested setTimeout() calls is that it is possible to add a timeout in a timeout callback such that it fires on the same iteration of the event loop in which it was added. I didn't see a note in the documentation to say whether this should be allowed or not (whereas there is such a note for setImmediate()), but perhaps I missed it? The above PR assumes that this scenario should not be allowed and if that is correct, then it looks like a good fix for this issue. And in that case I think we should update the doc to describe this contract under https://nodejs.org/api/timers.html#timers_settimeout_callback_delay_arg . |
@tunniclm Continued this discussion in the PR that fixes this issue itself, so that it's easier to see the actual changes along the comments: #25763 (comment). |
Whenever a timer with a specific timeout value creates a new timer with the same timeout, the newly added timer might be processed immediately in the same tick of the event loop instead of during the next tick of the event loop at the earliest. Fixes nodejs#25607
Whenever a timer with a specific timeout value creates a new timer with the same timeout, the newly added timer might be processed immediately in the same tick of the event loop instead of during the next tick of the event loop at the earliest. Fixes nodejs#25607
Whenever a timer is scheduled within another timer, there are a few known issues that we are fixing: * Whenever the timer being scheduled has the same timeout value as the outer timer, the newly created timer can fire on the same tick of the event loop instead of during the next tick of the event loop * Whenever a timer is added in another timer's callback, its underlying timer handle will be started with a timeout that is actually incorrect This commit consists of nodejs/node-v0.x-archive#17203 and nodejs/node-v0.x-archive#25763. Fixes: nodejs/node-v0.x-archive#9333 Fixes: nodejs/node-v0.x-archive#15447 Fixes: nodejs/node-v0.x-archive#25607 Fixes: nodejs#5426 PR-URL: nodejs#3063
Whenever a timer is scheduled within another timer, there are a few known issues that we are fixing: * Whenever the timer being scheduled has the same timeout value as the outer timer, the newly created timer can fire on the same tick of the event loop instead of during the next tick of the event loop * Whenever a timer is added in another timer's callback, its underlying timer handle will be started with a timeout that is actually incorrect This commit consists of nodejs/node-v0.x-archive#17203 and nodejs/node-v0.x-archive#25763. Fixes: nodejs/node-v0.x-archive#9333 Fixes: nodejs/node-v0.x-archive#15447 Fixes: nodejs/node-v0.x-archive#25607 Fixes: #5426 PR-URL: #3063
Whenever a timer is scheduled within another timer, there are a few known issues that we are fixing: * Whenever the timer being scheduled has the same timeout value as the outer timer, the newly created timer can fire on the same tick of the event loop instead of during the next tick of the event loop * Whenever a timer is added in another timer's callback, its underlying timer handle will be started with a timeout that is actually incorrect This commit consists of nodejs/node-v0.x-archive#17203 and nodejs/node-v0.x-archive#25763. Fixes: nodejs/node-v0.x-archive#9333 Fixes: nodejs/node-v0.x-archive#15447 Fixes: nodejs/node-v0.x-archive#25607 Fixes: #5426 PR-URL: #3063
test-microtask-queue-run
andtest-microtask-queue-run-domain
appear to be flaky (PR: #25606), failing very rarely. Testing 10k runs on the platforms I have available, I got failure rates as high as:OK: 9964 NOT OK: 36
OK: 9843 NOT OK: 157
OK: 9904 NOT OK: 96
The results appear to be influenced by the machine load, I got much lower results on an otherwise idle machine.
Quick test:
Other tests from
test-microtask-queue-*
seem okay.The text was updated successfully, but these errors were encountered: