fix: enable SSE reconnect in multi-user client - #228
Open
vazarkevych wants to merge 2 commits into
Open
Conversation
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.
Problem
In multi-user mode,
GrowthBookClientalways called the no-argrepository.initialize()(ininitializeFeaturesRepository()), which delegates toinitialize(false). That hardwiresretryOnFailure = false, soscheduleSseReconnect(...)early-returns and the SSE reconnect machinery is unreachable.As a result, a
GrowthBookClientusingFeatureRefreshStrategy.SERVER_SENT_EVENTSpermanently stops receiving feature updates after the first abnormal stream failure
(connection reset, proxy/pod restart, mid-stream IOException) — silently:
schedulePolling()early-returns for SSE);FeatureRefreshCallback.onError(...)never fires.Both
onFailureandonCloseroute throughscheduleSseReconnect, so multi-user + SSEalso stops reconnecting on a graceful close.
Options.retryPolicy(exponentialbackoff) was configurable but never actually engaged.
Fix
Expose the flag on
Optionsand thread it through the single choke point:Options.sseReconnectOnFailure— new option, defaults totrue, withisSseReconnectOnFailure()returningtrueunless explicitly disabled. Added as thelast constructor parameter to preserve the existing positional constructor signature.
GrowthBookClient.initializeFeaturesRepository()now callsrepository.initialize(options.isSseReconnectOnFailure())instead of the no-arg form.Reconnect is on by default (bounded by
retryPolicy), and callers can opt out withOptions.builder().sseReconnectOnFailure(false). The single-userGBFeaturesRepository.initialize()default (false) is unchanged to avoid a broaderpublic-API behavior change.
Tests
backoff) was configurable but never actually engaged.
Fix
Expose the flag on
Optionsand thread it through the single choke point:Options.sseReconnectOnFailure— new option, defaults totrue, withisSseReconnectOnFailure()returningtrueunless explicitly disabled. Added as thelast constructor parameter to preserve the existing positional constructor signature.
GrowthBookClient.initializeFeaturesRepository()now callsrepository.initialize(options.isSseReconnectOnFailure())instead of the no-arg form.Reconnect is on by default (bounded by
retryPolicy), and callers can opt out withOptions.builder().sseReconnectOnFailure(false). The single-userGBFeaturesRepository.initialize()default (false) is unchanged to avoid a broaderpublic-API behavior change.