Repository navigation
test: fix flaky canIterateEvents test caused by PipedInputStream timing - #107
Merged
Merged
Conversation
PipedInputStream.read() has a built-in wait(1000) when the pipe buffer is empty. If the pipe writer thread hasn't written data before EventSource starts reading, this causes up to a 1-second delay. Combined with the 1-second queue poll timeout, the poll can expire just as data arrives. Increase poll timeouts from 1s to 5s. The tests remain fast because poll returns immediately when data arrives. Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
tanderson-ld
approved these changes
Jun 9, 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.
Summary
EventSourceReadingTest.canIterateEventsflakes on CI becausePipedInputStream.read()has a built-inwait(1000)when its buffer is empty. When the pipe writer thread hasn't written data before EventSource starts reading, this causes up to a 1-second delay before data is delivered. The test'squeue.poll(1, TimeUnit.SECONDS)then races with the arriving data, failing when the timeout expires just as the event is enqueued.Increases poll timeouts from 1s to 5s in
canIterateEvents. The tests remain fast becausepollreturns immediately when data arrives.CI failure: https://github.com/launchdarkly/okhttp-eventsource/actions/runs/27165957135/job/80193033816?pr=106
Link to Devin session: https://app.devin.ai/sessions/49e559fb4a04401dbb09d7cc3535d66b
Requested by: @kinyoklion
Note
Low Risk
Test-only timeout adjustments with no production or library behavior changes.
Overview
Addresses CI flakiness in
canIterateEventsby wideningBlockingQueue.pollandSemaphore.tryAcquirewaits from 1s to 5s when the test thread waits on events from a backgroundanyEvents()iterator.The change only affects test synchronization margins against
PipedInputStreamtiming (up to ~1s when the pipe buffer is empty);poll/tryAcquirestill return as soon as data is available, so passing runs should stay fast.Reviewed by Cursor Bugbot for commit d3e16cf. Bugbot is set up for automated code reviews on this repo. Configure here.