Skip to content

Fix flaky app-event-watcher test by replacing fragile setTimeout waits#7251

Merged
gonzaloriestra merged 1 commit intomainfrom
river-fix-flaky-app-event-watcher-test
Apr 13, 2026
Merged

Fix flaky app-event-watcher test by replacing fragile setTimeout waits#7251
gonzaloriestra merged 1 commit intomainfrom
river-fix-flaky-app-event-watcher-test

Conversation

@gonzaloriestra
Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

The generateExtensionTypes and build error tests used a fixed 10ms setTimeout to wait for the async event processing chain to complete. This chain involves multiple async operations (handleWatcherEvents, updateContexts, rescanImports, buildExtensions, generateExtensionTypes, emit) and 10ms is not always enough.

WHAT is this pull request doing?

Replace all fragile setTimeout(10) waits with a polling mechanism that waits for the watcher's 'all' event to be emitted, matching the approach already used by the test.each block in the same file. This ensures tests only proceed once the full async processing chain has completed.

How to test your changes?

CI

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing, so I've added a changelog entry with pnpm changeset add

The generateExtensionTypes and build error tests used a fixed 10ms setTimeout
to wait for the async event processing chain to complete. This chain involves
multiple async operations (handleWatcherEvents, updateContexts, rescanImports,
buildExtensions, generateExtensionTypes, emit) and 10ms is not always enough.

Replace all fragile setTimeout(10) waits with a polling mechanism that waits
for the watcher's 'all' event to be emitted, matching the approach already
used by the test.each block in the same file. This ensures tests only proceed
once the full async processing chain has completed.
@gonzaloriestra gonzaloriestra marked this pull request as ready for review April 13, 2026 09:48
@gonzaloriestra gonzaloriestra requested a review from a team as a code owner April 13, 2026 09:48
@gonzaloriestra gonzaloriestra added this pull request to the merge queue Apr 13, 2026
Merged via the queue into main with commit abc5566 Apr 13, 2026
24 of 25 checks passed
@gonzaloriestra gonzaloriestra deleted the river-fix-flaky-app-event-watcher-test branch April 13, 2026 10:13
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.

2 participants