Skip to content

test: drain transient STATUS results in errorEventFromServer test#340

Merged
aaron-zeisler merged 1 commit intomainfrom
devin/1774996778-fix-flaky-fdv2-error-event-test
Apr 2, 2026
Merged

test: drain transient STATUS results in errorEventFromServer test#340
aaron-zeisler merged 1 commit intomainfrom
devin/1774996778-fix-flaky-fdv2-error-event-test

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot commented Mar 31, 2026

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

  • SDK-2111 — Flaky test: FDv2StreamingSynchronizerTest.errorEventFromServer intermittently returns STATUS instead of CHANGE_SET

Describe the solution you've provided

The errorEventFromServer test previously called sync.next() exactly once and asserted the result was CHANGE_SET. Under resource contention (full test suite), the EventSource can experience a transient connection fault before the SSE events arrive, producing a STATUS(INTERRUPTED) that beats the expected CHANGE_SET into the result queue.

The fix replaces the single next() call with a drain loop (up to 10 iterations) that consumes and asserts on transient STATUS results until the expected CHANGE_SET arrives. This mirrors the existing pattern already used by reconnectAfterPartialProtocolSequenceDeliversChangeset in the same test class, and reflects real-world SourceManager behavior which calls next() in a loop.

No production code is changed.

Items for reviewer attention:

  • The per-iteration timeout is 5 seconds, but the class-level @Rule Timeout.seconds(10) will kill the test well before 10 × 5s. Verify this interaction is acceptable.
  • Consider whether other tests in this file (e.g. heartbeatEvent, shutdownAfterEventReceived) could be similarly flaky and benefit from the same pattern.

Describe alternatives you've considered

  • Server-ready synchronization barrier (Option B in the ticket): harder to implement reliably since the flakiness may be caused by thread scheduling delays, not connection failures.
  • Suppress transient faults in production handleError() (Option C): inappropriate since the current production behavior of reporting every interruption is correct.

Additional context

The JIRA ticket description was also reformatted (escaped markdown from Cursor was rendering poorly in Jira).

Link to Devin session: https://app.devin.ai/sessions/555f5a4faf774eba9d03b6c61e12402e


Note

Low Risk
Low risk because changes are confined to a unit/integration test; it only adjusts assertions to tolerate transient STATUS(INTERRUPTED) results that can occur under contention.

Overview
Makes FDv2StreamingSynchronizerTest.errorEventFromServer non-flaky by no longer assuming the first sync.next() result is a CHANGE_SET.

The test now drains up to 10 queued STATUS results (asserting they are STATUS) until the expected CHANGE_SET arrives, then asserts the changeset is present.

Written by Cursor Bugbot for commit bb26cd4. This will update automatically on new commits. Configure here.

Under resource contention the EventSource may experience a transient
connection fault before the SSE events arrive, producing a
STATUS(INTERRUPTED) that beats the expected CHANGE_SET into the result
queue. This mirrors the existing pattern used by
reconnectAfterPartialProtocolSequenceDeliversChangeset.

Fixes SDK-2111

Co-Authored-By: Aaron Zeisler <azeisler@launchdarkly.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 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 and CI monitoring

@aaron-zeisler aaron-zeisler marked this pull request as ready for review March 31, 2026 22:48
@aaron-zeisler aaron-zeisler requested a review from a team as a code owner March 31, 2026 22:48
@aaron-zeisler aaron-zeisler merged commit d146cde into main Apr 2, 2026
9 checks passed
@aaron-zeisler aaron-zeisler deleted the devin/1774996778-fix-flaky-fdv2-error-event-test branch April 2, 2026 16:18
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