-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
fix(test): Improve reliability of deno test
's op sanitizer with timers
#12908
fix(test): Improve reliability of deno test
's op sanitizer with timers
#12908
Conversation
Although not easy to replicate in the wild, the `deno test` op sanitizer can fail when there are intervals that started before a test runs, since the op sanitizer can end up running in the time between the timer op for an interval's run resolves and the op for the next run starts. This change fixes that by adding a new macrotask callback that will run after the timer macrotask queue has drained. This ensures that there is a timer op if there are any timers which are unresolved by the time the op sanitizer runs.
deno test
's op sanitizer around timersdeno test
's op sanitizer with timers
cbe41d5
to
237d44a
Compare
This is needed to fix some of the CI failures in #12862 |
@bartlomieju @caspervonb PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I verified that provided test case fails on main
. Good fix @andreubotella
…ers (denoland#12908) Although not easy to replicate in the wild, the `deno test` op sanitizer can fail when there are intervals that started before a test runs, since the op sanitizer can end up running in the time between the timer op for an interval's run resolves and the op for the next run starts. This change fixes that by adding a new macrotask callback that will run after the timer macrotask queue has drained. This ensures that there is a timer op if there are any timers which are unresolved by the time the op sanitizer runs.
This change seems breaking some test cases in deno_std (e.g. |
Reproduced the issue with a smaller example. It seems related to nextTick: import { nextTick } from "https://deno.land/std@0.116.0/node/_next_tick.ts";
Deno.test("test 1", async () => {
await new Promise<void>((resolve) => nextTick(resolve));
});
Deno.test("test 2", async () => {
await new Promise<void>((resolve) => nextTick(resolve));
}); The above example is stuck at the end of |
…with timers (denoland#12908)" This reverts commit d335343.
…with timers (denoland#12908)" This reverts commit d335343.
See denoland#12771 and denoland#12814. Needed to reland denoland#12908, which was reverted in denoland#12929.
Although not easy to replicate in the wild, the
deno test
op sanitizer can fail when there are intervals that started before a test runs, since the op sanitizer can end up running in the time between the timer op for an interval's run resolves and the op for the next run starts.This change fixes that by adding a new macrotask callback that will run after the timer macrotask queue has drained. This ensures that there is a timer op if there are any timers which are unresolved by the time the op sanitizer runs.