Skip to content

test: fix flaky event_reported_while_polling test#507

Open
kinyoklion wants to merge 5 commits into
v11from
devin/1780589904-fix-flag-synchronizer-polling-flake
Open

test: fix flaky event_reported_while_polling test#507
kinyoklion wants to merge 5 commits into
v11from
devin/1780589904-fix-flag-synchronizer-polling-flake

Conversation

@kinyoklion
Copy link
Copy Markdown
Member

@kinyoklion kinyoklion commented Jun 4, 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

Follows up on #486 which addressed other flaky FlagSynchronizerSpec polling tests but left a remaining race in streaming_events__event_reported_while_polling__reports_an_event_error.

Describe the solution you've provided

The onSyncComplete closure inside the waitUntil block called done() for any sync result, including poll-triggered completions from the still-active polling timer. When the 1-second timer fired during the waitUntil window, done() was called twice — once from the poll result and once from the stream event — producing Nimble's waitUntil(..) expects its completion closure to be only called once error.

The fix filters onSyncComplete to only call done() when the expected .streamEventWhilePolling error arrives, ignoring poll results (.error(.response(nil)) from the unstubbed mock).

Describe alternatives you've considered

  • Adding a didCallDone guard (used in the LDTimerSpec fix) — works but would mask the poll result overwriting syncError if timing is unlucky.
  • Stopping the polling timer before the waitUntil block — changes the scenario under test.

Additional context

Test-only change; no application code modified.

Link to Devin session: https://app.devin.ai/sessions/e40ffc3296dd45648f86ac10c42b6da5
Requested by: @kinyoklion


Note

Low Risk
Test-only change in FlagSynchronizerSpec; no application or synchronizer production logic modified.

Overview
Fixes flakiness in streamingProcessingSpec’s event reported while polling example by tightening when the Nimble waitUntil completion runs.

The onSyncComplete handler no longer calls done() on every .error sync result. It now completes only when the error is .streamEventWhilePolling, so incidental poll completions from the active 1s polling timer during waitUntil no longer invoke done() a second time (Nimble’s “completion closure called only once” failure).

Reviewed by Cursor Bugbot for commit f87c80f. Bugbot is set up for automated code reviews on this repo. Configure here.

The onSyncComplete closure in the waitUntil block called done() for
any sync result, including poll-triggered completions from the still-
active polling timer. When the timer fired during the waitUntil window,
done() was called twice: once from the poll result and once from the
stream event.

Filter the onSyncComplete callback to only call done() when the
expected .streamEventWhilePolling error arrives, ignoring poll results.

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

Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
@kinyoklion kinyoklion marked this pull request as ready for review June 4, 2026 16:30
@kinyoklion kinyoklion requested a review from a team as a code owner June 4, 2026 16:30
devin-ai-integration Bot and others added 3 commits June 4, 2026 16:31
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
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