test: fix flaky event_reported_while_polling test#507
Open
kinyoklion wants to merge 5 commits into
Open
Conversation
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>
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:
|
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>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
keelerm84
approved these changes
Jun 4, 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.
Requirements
Related issues
Follows up on #486 which addressed other flaky
FlagSynchronizerSpecpolling tests but left a remaining race instreaming_events__event_reported_while_polling__reports_an_event_error.Describe the solution you've provided
The
onSyncCompleteclosure inside thewaitUntilblock calleddone()for any sync result, including poll-triggered completions from the still-active polling timer. When the 1-second timer fired during thewaitUntilwindow,done()was called twice — once from the poll result and once from the stream event — producing Nimble'swaitUntil(..) expects its completion closure to be only called onceerror.The fix filters
onSyncCompleteto only calldone()when the expected.streamEventWhilePollingerror arrives, ignoring poll results (.error(.response(nil))from the unstubbed mock).Describe alternatives you've considered
didCallDoneguard (used in theLDTimerSpecfix) — works but would mask the poll result overwritingsyncErrorif timing is unlucky.waitUntilblock — 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 NimblewaitUntilcompletion runs.The
onSyncCompletehandler no longer callsdone()on every.errorsync result. It now completes only when the error is.streamEventWhilePolling, so incidental poll completions from the active 1s polling timer duringwaitUntilno longer invokedone()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.