Skip to content

feat: expose setConnectionMode on browser SDK#1232

Open
kinyoklion wants to merge 9 commits intomainfrom
rlamb/fdv2-set-connection-mode
Open

feat: expose setConnectionMode on browser SDK#1232
kinyoklion wants to merge 9 commits intomainfrom
rlamb/fdv2-set-connection-mode

Conversation

@kinyoklion
Copy link
Copy Markdown
Member

@kinyoklion kinyoklion commented Mar 27, 2026

Summary

  • Adds setConnectionMode(mode?: FDv2ConnectionMode) to the browser SDK's LDClient interface as an EAP method, giving users direct control over the connection mode with higher priority than setStreaming
  • Introduces BrowserDataSystemOptions type that restricts automaticModeSwitching to false | ManualModeSwitching only, removing the automatic option which has no impact for the browser SDK
  • Adds optional setConnectionMode to the shared DataManager interface following the same pattern as setForcedStreaming
  • Adds connection mode control buttons to the FDv2 example app for testing all modes

Note

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 through BrowserClient to an optional DataManager.setConnectionMode implementation with validation and warnings when FDv2 isn’t enabled.

Introduces BrowserDataSystemOptions (exported from the package) to constrain browser dataSystem.automaticModeSwitching to false | 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.

@github-actions
Copy link
Copy Markdown
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 25661 bytes
Compressed size limit: 29000
Uncompressed size: 126143 bytes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 179331 bytes
Compressed size limit: 200000
Uncompressed size: 829227 bytes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 37015 bytes
Compressed size limit: 38000
Uncompressed size: 202741 bytes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 31556 bytes
Compressed size limit: 34000
Uncompressed size: 112044 bytes

…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.
@kinyoklion kinyoklion force-pushed the rlamb/fdv2-set-connection-mode branch from 21348e5 to 86b6ae4 Compare March 30, 2026 18:20
@kinyoklion kinyoklion marked this pull request as ready for review March 30, 2026 18:25
@kinyoklion kinyoklion requested a review from a team as a code owner March 30, 2026 18:25
Copy link
Copy Markdown
Contributor

@joker23 joker23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a future consideration comment

return this._startPromise;
}

setConnectionMode(mode?: FDv2ConnectionMode): void {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should probably add a warning now.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

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