stabilize DebouncedChan continuous test#1172
Merged
Conversation
The continuous-operation debounce test was flaky under CI load because it assumed wall-clock timing from repeated `time.Sleep(1ms)` calls. On a busy runner with `-race`, that loop can take much longer than nominal and produce more debounce cycles than the fixed expectation allows. Flaky run: https://github.com/riverqueue/river/actions/runs/23099889445/job/67098683719 ```text --- FAIL: TestDebouncedChan_ContinuousOperation (0.25s) debounced_chan_test.go:159: Expected: 10, actual: 14 debounced_chan_test.go:160: Error: Max difference between 10 and 14 allowed is 3, but difference was -4 ``` Rewrite the test to run inside `testing/synctest` with fake time and explicit cooldown periods. The assertions now check an exact, deterministic count, including one final trailing-edge signal, and the test includes targeted comments around the subtle synchronization points.
brandur
approved these changes
Mar 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The continuous-operation debounce test was flaky under CI load because it assumed wall-clock timing from repeated
time.Sleep(1ms)calls. On a busy runner with-race, that loop can take much longer than nominal and produce more debounce cycles than the fixed expectation allows.A recent flaky run from tonight: https://github.com/riverqueue/river/actions/runs/23099889445/job/67098683719
Rewrite the test to run inside
testing/synctestwith fake time and explicit cooldown periods. The assertions now check an exact, deterministic count, including one final trailing-edge signal, and the test includes targeted comments around the subtle synchronization points.