-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Spurious assertion error when the callback to setInterval lasts longer than the interval #11398
Comments
For reference the entire setTimeout code is so complicated because back when we implemented We would need to figure out how to be able to cancel this ongoing timer, but overall I think this should greatly simplify 01_timers.js and likely fix this bug. |
This is true, however its not that breaking for my application so for me it does not have a big prio |
I believe this might be causing the same issue I'm seeing right now with rxjs under heavy load:
|
Just having the Deno.test(async function clearTimeoutAfterNextTimerIsDue1() {
const promise = deferred();
setTimeout(() => {
promise.resolve();
}, 300);
const interval = setInterval(() => {
Deno.sleepSync(400);
// Both the interval and the timeout's due times are now in the past.
clearTimeout(interval);
}, 100);
await promise;
}); The bug is due to an interaction between various timers that happens when calling Deno.test(async function clearTimeoutAfterNextTimerIsDue2() {
const promise = deferred();
const timeout1 = setTimeout(() => {}, 100);
setTimeout(() => {
promise.resolve();
}, 200);
Deno.sleepSync(300);
// Both of the timeouts' due times are now in the past.
clearTimeout(timeout1);
await promise;
}); This issue will be fixed in the rewrite of timers I'm doing in #12862. |
This change also makes the timers implementation closer to the spec, and sets up the stage to implement `AbortSignal.timeout()` (whatwg/dom#1032). Fixes denoland#8965. Fixes denoland#10974. Fixes denoland#11398.
This change also makes the timers implementation closer to the spec, and sets up the stage to implement AbortSignal.timeout() (whatwg/dom#1032). Fixes #8965 Fixes #10974 Fixes #11398
Attacler/Bart reported on Discord that an
AssertionError
was being thrown while they were stress-testing their code. It seems to happen spuriously, but their stress test seemed to hit it every time.Since the failed assertion makes sure that the timeout is not lesser than zero, and changing the interval to 4000ms solved the problem, it seems to be caused by the callback taking longer to run than the interval.
The text was updated successfully, but these errors were encountered: