You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test_runner: mocked timeout.refresh does not reschedule or reactivate a timeout #67577
const{ mock }=require('node:test');mock.timers.enable({apis: ['setTimeout']});letfired=0;constt=setTimeout(()=>{fired++;},100);mock.timers.tick(60);t.refresh();// should reschedule for t = 160mock.timers.tick(60);// t = 120console.log('at 120ms:',fired);mock.timers.tick(40);// t = 160console.log('at 160ms:',fired);t.refresh();// should re-arm the fired timeout for t = 260mock.timers.tick(100);// t = 260console.log('at 260ms:',fired);mock.timers.reset();
Run:
node repro.cjs
How often does it reproduce? Is there a required condition?
Every run with setTimeout mocked, both before the timeout fires and after it has fired.
What is the expected behavior? Why is that the expected behavior?
at 120ms: 0
at 160ms: 1
at 260ms: 2
The timeout.refresh documentation says it resets the start time to the current time while retaining the duration, and reactivates a timer that has already fired. Refreshing the 100 ms timeout at 60 ms should move it to 160 ms; refreshing again at 160 ms should move it to 260 ms.
What do you see instead?
The listed versions produce:
at 120ms: 1
at 160ms: 1
at 260ms: 1
Additional information
The mock Timeout refresh method currently returns this without updating the execution queue. #62820 adds close/dispose support but does not implement refresh.
AI tools assisted with analysis and preparation of this report and its reproduction. A human has reviewed and confirmed the issue and verified that it is reproducible.
Activity