Skip to content

test: fix flaky canIterateEvents test caused by PipedInputStream timing - #107

Merged
kinyoklion merged 1 commit into
mainfrom
devin/1780956288-fix-canIterateEvents-flake
Jun 9, 2026
Merged

kinyoklion merged 1 commit into
mainfrom
devin/1780956288-fix-canIterateEvents-flake

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Jun 8, 2026 •

Copy link
Copy Markdown
Member

Summary

EventSourceReadingTest.canIterateEvents flakes on CI because PipedInputStream.read() has a built-in wait(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's queue.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 because poll returns 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 canIterateEvents by widening BlockingQueue.poll and Semaphore.tryAcquire waits from 1s to 5s when the test thread waits on events from a background anyEvents() iterator.

The change only affects test synchronization margins against PipedInputStream timing (up to ~1s when the pipe buffer is empty); poll/tryAcquire still 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.

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>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@kinyoklion
kinyoklion marked this pull request as ready for review June 8, 2026 22:12
@kinyoklion
kinyoklion requested a review from a team June 8, 2026 22:12
@kinyoklion
kinyoklion merged commit 3a1b2fc into main Jun 9, 2026
9 checks passed
@kinyoklion
kinyoklion deleted the devin/1780956288-fix-canIterateEvents-flake branch June 9, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants