Skip to content

Fix flaky async abort test by using fake timers (#294)#301

Merged
platypii merged 1 commit intohyparam:masterfrom
jpetitcolas:unskip_flaky_test
Oct 13, 2025
Merged

Fix flaky async abort test by using fake timers (#294)#301
platypii merged 1 commit intohyparam:masterfrom
jpetitcolas:unskip_flaky_test

Conversation

@jpetitcolas
Copy link
Copy Markdown
Contributor

@jpetitcolas jpetitcolas commented Oct 11, 2025

Unskipped and refactored the aborts data fetch when scrolling fast test to eliminate timing-based flakiness observed in CI.

Hypothesis: The test was flaky in CI due to timing variations between environments. Real timers with 100ms delays could behave unpredictably under varying system load, causing race conditions in async operations.

  • Use vi.useFakeTimers() for deterministic time control (in association with vi.advanceTimersByTimeAsync())
  • Add afterEach cleanup to restore real timers

Hopefully, this test should now not be flaky anymore and run slightly faster.

Unskipped and refactored the "aborts data fetch when scrolling fast" test
to eliminate timing-based flakiness observed in CI.

Hypothesis: The test was flaky in CI due to timing variations between
environments. Real timers with 100ms delays could behave unpredictably
under varying system load, causing race conditions in async operations.

Solution:
- Use vi.useFakeTimers() for deterministic time control
- Replace findByRole (async, uses real timers) with queryByRole (sync)
- Explicitly advance timers with vi.advanceTimersByTimeAsync()
- Add afterEach cleanup to restore real timers

Benefits:
- Test is now deterministic and immune to system timing variations
- Execution time reduced from ~1370ms to ~666ms (nearly 2x faster)
- Maintains test validity while eliminating CI flakiness

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@platypii platypii requested a review from severo October 11, 2025 23:12
Copy link
Copy Markdown
Contributor

@severo severo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, great contribution!

@severo
Copy link
Copy Markdown
Contributor

severo commented Oct 13, 2025

Commits must have verified signatures.

@jpetitcolas can you sign your commits?

Or @platypii do you know if we can override this restriction (squash and merge will not use initial commits anyway)? (I cannot do it myself)
Screenshot From 2025-10-13 15-21-46

@platypii platypii merged commit 52826e0 into hyparam:master Oct 13, 2025
5 checks passed
@severo severo mentioned this pull request Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants