-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
test_runner: mock timer promisified setTimeout cleanup goes wrong losing some timers #50365
Comments
mika-fischer
added a commit
to mika-fischer/node
that referenced
this issue
Oct 25, 2023
Removal of mocket timers from the priority queue was broken. It used the timerId instead of the position in the queue as index. This lead to removal of incorrect timers from the queue causing timers not to be scheduled at all. Also, aborts caused removal from the queue even when the timer was already triggered, and thus no longer present in the queue. Fixes: nodejs#50365
mika-fischer
added a commit
to mika-fischer/node
that referenced
this issue
Oct 25, 2023
Removal of mocket timers from the priority queue was broken. It used the timerId instead of the position in the queue as index. This lead to removal of incorrect timers from the queue causing timers not to be scheduled at all. Also, aborts caused removal from the queue even when the timer was already triggered, and thus no longer present in the queue. Fixes: nodejs#50365
nodejs-github-bot
pushed a commit
that referenced
this issue
Nov 12, 2023
targos
pushed a commit
that referenced
this issue
Nov 23, 2023
UlisesGascon
pushed a commit
that referenced
this issue
Dec 11, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version
v20.5.1
Platform
Linux s7 5.15.0-69-generic #76-Ubuntu SMP Fri Mar 17 17:19:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
test
What steps will reproduce the bug?
The promisified mocked setTimeout sometimes cleans up the wrong timers. This always happens if the id of the timer diverges from the position in the priority queue.
The main reason is that the id of the timer is passed to PriorityQueue.removeAt instead of the position in the priority queue. Additionally, if the signal passed to setTimeout is aborted after the timer already fired, removeAt will be called, even though the timer is no longer in the priority queue.
I can prepare a PR for this. Should I base this on #50331 or on main?
fails with
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
All timers should fire and be cleaned up as expected
What do you see instead?
Some timers never fire because they are cleaned up eronseously
Additional information
No response
The text was updated successfully, but these errors were encountered: