feat: expose setConnectionMode on browser SDK#1232
Conversation
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/browser size report |
|
@launchdarkly/js-client-sdk-common size report |
|
@launchdarkly/js-client-sdk size report |
…mode switching Remove the automatic connection mode option from the browser SDK's public interface since it has no impact. Add setConnectionMode as an EAP method on the browser LDClient, giving users direct control over the connection mode with higher priority than setStreaming.
Add a Connection Mode control section with buttons for each FDv2ConnectionMode (streaming, polling, offline, one-shot, background) and a Clear button to reset to automatic mode selection.
21348e5 to
86b6ae4
Compare
joker23
left a comment
There was a problem hiding this comment.
Only a future consideration comment
| return this._startPromise; | ||
| } | ||
|
|
||
| setConnectionMode(mode?: FDv2ConnectionMode): void { |
There was a problem hiding this comment.
For future: setConnectionMode only affects FDv2 so, after we have this out of experimental, we should probably do something to signal that this function is a NOOP when using FDv1
There was a problem hiding this comment.
I should probably add a warning now.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Summary
setConnectionMode(mode?: FDv2ConnectionMode)to the browser SDK'sLDClientinterface as an EAP method, giving users direct control over the connection mode with higher priority thansetStreamingBrowserDataSystemOptionstype that restrictsautomaticModeSwitchingtofalse | ManualModeSwitchingonly, removing theautomaticoption which has no impact for the browser SDKsetConnectionModeto the sharedDataManagerinterface following the same pattern assetForcedStreamingNote
Medium Risk
Medium risk because it adds a new (experimental) client API that can override connection behavior and wires through to FDv2-only data managers; incorrect use could alter flag update/connection semantics.
Overview
Adds an experimental
LDClient.setConnectionMode(mode?: FDv2ConnectionMode)to the browser SDK, wiring it throughBrowserClientto an optionalDataManager.setConnectionModeimplementation with validation and warnings when FDv2 isn’t enabled.Introduces
BrowserDataSystemOptions(exported from the package) to constrain browserdataSystem.automaticModeSwitchingtofalse | ManualModeSwitching, and updates the FDv2 example app with UI controls to force/clear connection mode overrides for testing.Written by Cursor Bugbot for commit 52eafe2. This will update automatically on new commits. Configure here.