We understand you have a problem and are in a hurry, but please provide us with some info to make it much more likely for your issue to be understood, worked on and resolved quickly.
FakeTimers version : 9.1.2
Environment : MACOS
Example URL : a minimial reproduction test
Other libraries you are using: none
What did you expect to happen?
An infinite loop shouldn't be possible and this test shouldn't break
What actually happens
This test times out
How to reproduce
Here is a minimal test to reproduce the issue
it("new timers created from promises cannot cause an infinite loop when a date is given", function () {
this.clock = FakeTimers.createClock(Date.now());
const test = this;
const spy = sinon.spy();
const recursiveCallback = function () {
global.Promise.resolve().then(function () {
test.clock.setTimeout(recursiveCallback, 0);
});
};
this.clock.setTimeout(recursiveCallback, 0);
this.clock.setTimeout(spy, 100);
return this.clock.runToLastAsync().then(function () {
assert.isTrue(spy.called);
});
});
While working on https://github.com/vitest-dev/vitest/pull/2209 I have an issue with
runToLastAsync
doing an infinite loop Below you can find a minimal test to reproduce the issueFakeTimers version : 9.1.2
Environment : MACOS
Example URL : a minimial reproduction test
Other libraries you are using: none
What did you expect to happen? An infinite loop shouldn't be possible and this test shouldn't break
What actually happens This test times out
How to reproduce Here is a minimal test to reproduce the issue
The error for this test is