Skip to content

test_runner: forget queue position of reset mock timers - #67621

Open
sudoeren wants to merge 1 commit into
nodejs:mainfrom
sudoeren:test-runner-mock-timers-reset
Open

sudoeren wants to merge 1 commit into
nodejs:mainfrom
sudoeren:test-runner-mock-timers-reset

Conversation

@sudoeren

Copy link
Copy Markdown

MockTimers#reset() emptied the execution queue but left priorityQueuePosition set on the removed timers. Clearing such a stale timer later (for example a timer from a previous test, cleared after the next test enabled its own mock timers) removed whichever timer sat at that position in the new queue, so that timer never fired.

reset() now clears the position of each timer it removes, so #clearTimer() treats them as no longer queued.

Two tests are added: one for a timer cleared after reset() on the same instance, and one for a timer from another MockTracker instance (the case in the issue). Both fail without the change.

Fixes: #67593

`MockTimers#reset()` emptied the execution queue but left
`priorityQueuePosition` set on the removed timers. Clearing such a
stale timer later, for example from a previous test after the next
test enabled its own mock timers, removed whichever timer sat at that
position in the new queue, so that timer never fired.

Fixes: nodejs#67593
Signed-off-by: sudoeren <hey@erencakar.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_runner: clearTimeout() of a timer from a previous test's mock removes a timer of the current test

2 participants