feat: FDv2DataManagerBase for mode switching and data source lifecycle#1210
Conversation
…xtensions Add InitializerEntry/SynchronizerEntry types for type-safe mode definitions, refine protocolHandler validation to use isNullish for version/target fields, add connectionModes config option, split validator arrays for initializers vs synchronizers, and extend DataManager with optional streaming/flush methods.
Add applyChanges method to FlagManager and FlagPersistence that handles full replacement, partial upsert, and no-change persistence in a single call, designed for the FDv2 data path.
Add SourceFactoryProvider that converts declarative InitializerEntry and SynchronizerEntry config into concrete initializer factories and synchronizer slots, with support for per-entry endpoint and interval overrides.
…data-manager-base
…cycle Add shared data manager that orchestrates FDv2 connection mode switching, state debouncing, streaming control, and data source lifecycle management. Implements the DataManager interface with support for foreground/background modes, forced/automatic streaming, and flush callbacks.
- Fix ping handler to use per-entry endpoint-overridden requestor and the factory's selector getter (sg) for fresh selectors on each ping - Extract duplicated streaming base config into shared buildStreamingBase helper - Restructure SourceFactoryContext to group polling/streaming config into nested objects (polling.paths, polling.intervalSeconds, streaming.paths, streaming.initialReconnectDelaySeconds) - Resolve merge conflict in FDv2DataSource (warn -> debug)
Adapt factory context construction to use nested polling/streaming config objects and remove selectorGetter from the context (now passed directly via factory sg parameter).
Account for new FDv2 SourceFactoryProvider and related code paths.
… checks Push applyChanges down through the flag manager layers so the FDv2 path no longer routes through FDv1's upsert (which has version checks and inactive-context guards). FlagStore.applyPartial inserts without version comparison, and FlagUpdater.applyChanges sets the active context directly and emits change events.
…data-manager-base
…er-apply-changes # Conflicts: # packages/shared/sdk-client/src/datasource/fdv2/FDv2DataSource.ts
…er-base # Conflicts: # packages/shared/sdk-client/src/index.ts
Account for new FDv2 applyChanges code in FlagUpdater/FlagStore that flows into the browser SDK bundle.
…data-manager-base
…data-manager-base
Replace FlagStore.applyPartial with FlagStore.applyChanges that handles full/partial/none, delegating to init for full. FlagUpdater.applyChanges now delegates storage to FlagStore.applyChanges and only handles change event computation.
…data-manager-base
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/browser size report |
|
@launchdarkly/js-client-sdk-common size report |
…onnectionMode - Remove initialConnectionMode from LDClientDataSystemOptions - Add ManualModeSwitching interface (type: 'manual' + initialConnectionMode) - Add type: 'automatic' discriminant to AutomaticModeSwitchingConfig - Rename PlatformDataSystemDefaults.initialConnectionMode to foregroundConnectionMode - Update validators to accept boolean | automatic config | manual config - Update all tests for new shape
| credentialType: 'clientSideId', | ||
| dataSystemDefaults: { | ||
| initialConnectionMode: 'one-shot', | ||
| foregroundConnectionMode: 'one-shot', |
There was a problem hiding this comment.
This is now the platform specific default, and not the same thing as the initial connection mode.
The config field represents the configured foreground mode, not just the initial one. Internally aliased to configuredForegroundMode to avoid collision with the mutable foregroundMode state variable.
Clear the selector when an FDv1 synchronizer delivers a payload without state, preventing stale selectors from being sent on subsequent requests.
…e leak If close() is called while namespaceForEnvironment is pending, identify would resume and create a data source and debounce manager that would never be cleaned up. Add a guard after the await to bail out early.
Update automaticModeSwitching docs to reference AutomaticModeSwitchingConfig and ManualModeSwitching types instead of re-declaring the shape inline. Add discriminant docs and cross-references to related types.
…n table Replace setRequestedMode and setForegroundMode with setConnectionMode that sets an explicit connection mode override. When set, it bypasses the entire transition table (network, lifecycle, streaming logic). Pass undefined to clear and return to automatic behavior. Priority hierarchy: 1. connectionModeOverride (setConnectionMode) 2. Transition table with foreground mode from: a. forcedStreaming b. automaticStreaming c. configuredForegroundMode
…ction The synchronous flag updates and change events are the critical path. The returned promise is only for async cache persistence — intentionally not awaited so the data source pipeline isn't blocked by storage I/O.
Add optional is parameter to validatorOf so anyOf can discriminate between object shapes by checking a type field. Split mode switching validators into separate automatic and manual variants with type-based is predicates.
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.
| NetworkState, | ||
| PendingState, | ||
| ReconciliationCallback, | ||
| } from './datasource/StateDebounceManager'; |
There was a problem hiding this comment.
LifecycleState missing from StateDebounceManager re-exports
Low Severity
NetworkState is re-exported from StateDebounceManager but its sibling type LifecycleState is not, even though both are used symmetrically in the exported FDv2DataManagerControl interface (setNetworkState and setLifecycleState). While LifecycleState is available from the api/datasource export path, the asymmetry in the StateDebounceManager export block is confusing for consumers looking at these related types side-by-side.
## Summary - Conditionally use `FDv2DataManagerBase` when `dataSystem` config is present, falling back to `BrowserDataManager` for FDv1 - Derive foreground mode from `ManualModeSwitching.initialConnectionMode` or browser platform default - Use optional chaining for `setForcedStreaming`/`setAutomaticStreamingState`/`setFlushCallback` via the `DataManager` interface methods - Update `combined-browser.yml` bundle size limit for FDv2 code paths Stacked on #1210. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Introduces a conditional switch between FDv1 and FDv2 data paths in `BrowserClient`, which can affect endpoint selection and streaming behavior. Risk is mitigated by fallback to FDv1 when `dataSystem` is unset and added tests covering routing/validation behavior. > > **Overview** > **BrowserClient now conditionally uses FDv2**: when `configuration.dataSystem` is present, it instantiates `createFDv2DataManagerBase` (using `BROWSER_TRANSITION_TABLE`, `MODE_TABLE`, and FDv2 query params), otherwise it continues using the existing `BrowserDataManager`/FDv1 endpoints. > > **Streaming/flush integration is generalized** by calling `setForcedStreaming`, `setAutomaticStreamingState`, and `setFlushCallback` via optional chaining so the same client logic works across FDv1/FDv2 managers; explicit `streaming: false` is forwarded to prevent FDv2 auto-promotion. > > Adds `resolveForegroundMode` to derive FDv2 foreground mode from `ManualModeSwitching.initialConnectionMode` (or platform defaults), exports it from `sdk-client`, and extends browser tests to assert FDv1 vs FDv2 endpoint selection and that invalid `dataSystem` sub-options warn but still enable FDv2. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 04afb4e. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
🤖 I have created a release *beep* *boop* --- <details><summary>akamai-edgeworker-sdk-common: 2.0.18</summary> ## [2.0.18](akamai-edgeworker-sdk-common-v2.0.17...akamai-edgeworker-sdk-common-v2.0.18) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from ^2.18.3 to ^2.18.4 </details> <details><summary>akamai-server-base-sdk: 3.0.19</summary> ## [3.0.19](akamai-server-base-sdk-v3.0.18...akamai-server-base-sdk-v3.0.19) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/akamai-edgeworker-sdk-common bumped from ^2.0.17 to ^2.0.18 * @launchdarkly/js-server-sdk-common bumped from ^2.18.3 to ^2.18.4 </details> <details><summary>akamai-server-edgekv-sdk: 1.4.21</summary> ## [1.4.21](akamai-server-edgekv-sdk-v1.4.20...akamai-server-edgekv-sdk-v1.4.21) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/akamai-edgeworker-sdk-common bumped from ^2.0.17 to ^2.0.18 * @launchdarkly/js-server-sdk-common bumped from ^2.18.3 to ^2.18.4 </details> <details><summary>browser: 0.1.14</summary> ## [0.1.14](browser-v0.1.13...browser-v0.1.14) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk bumped from 4.4.1 to 4.5.0 </details> <details><summary>browser-telemetry: 1.0.30</summary> ## [1.0.30](browser-telemetry-v1.0.29...browser-telemetry-v1.0.30) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/js-client-sdk bumped from 4.4.1 to 4.5.0 </details> <details><summary>cloudflare-server-sdk: 2.7.18</summary> ## [2.7.18](cloudflare-server-sdk-v2.7.17...cloudflare-server-sdk-v2.7.18) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common-edge bumped from 2.6.16 to 2.6.17 </details> <details><summary>fastly-server-sdk: 0.2.10</summary> ## [0.2.10](fastly-server-sdk-v0.2.9...fastly-server-sdk-v0.2.10) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from 2.18.3 to 2.18.4 </details> <details><summary>jest: 1.0.9</summary> ## [1.0.9](jest-v1.0.8...jest-v1.0.9) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/react-native-client-sdk bumped from ~10.15.1 to ~10.15.2 </details> <details><summary>js-client-sdk: 4.5.0</summary> ## [4.5.0](js-client-sdk-v4.4.1...js-client-sdk-v4.5.0) (2026-04-14) ### Features * add retry logic to FDv2 polling initializer ([#1230](#1230)) ([fe8bd37](fe8bd37)) * expose setConnectionMode on browser SDK ([#1232](#1232)) ([9019808](9019808)) * FDv2 contract test wiring, suppressions, and example app, cleanup configuration exports. ([#1225](#1225)) ([c67c5f6](c67c5f6)) * wire FDv2 data manager into BrowserClient ([#1222](#1222)) ([0b855f0](0b855f0)) ### Bug Fixes * FDv2 - Support dynamic reconnect URL for streaming. Handle 'error' event types for SSE. ([#1252](#1252)) ([4ef6cdd](4ef6cdd)) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk-common bumped from 1.23.0 to 1.24.0 </details> <details><summary>js-client-sdk-common: 1.24.0</summary> ## [1.24.0](js-client-sdk-common-v1.23.0...js-client-sdk-common-v1.24.0) (2026-04-14) ### Features * add retry logic to FDv2 polling initializer ([#1230](#1230)) ([fe8bd37](fe8bd37)) * expose setConnectionMode on browser SDK ([#1232](#1232)) ([9019808](9019808)) * FDv2 contract test wiring, suppressions, and example app, cleanup configuration exports. ([#1225](#1225)) ([c67c5f6](c67c5f6)) * FDv2DataManagerBase for mode switching and data source lifecycle ([#1210](#1210)) ([8f8051c](8f8051c)) * support per-mode FDv1 fallback configuration ([#1246](#1246)) ([9956bce](9956bce)) * wire FDv2 data manager into BrowserClient ([#1222](#1222)) ([0b855f0](0b855f0)) ### Bug Fixes * FDv2 - Support dynamic reconnect URL for streaming. Handle 'error' event types for SSE. ([#1252](#1252)) ([4ef6cdd](4ef6cdd)) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-sdk-common bumped from 2.24.0 to 2.24.1 </details> <details><summary>js-sdk-common: 2.24.1</summary> ## [2.24.1](js-sdk-common-v2.24.0...js-sdk-common-v2.24.1) (2026-04-14) ### Bug Fixes * FDv2 - Support dynamic reconnect URL for streaming. Handle 'error' event types for SSE. ([#1252](#1252)) ([4ef6cdd](4ef6cdd)) </details> <details><summary>js-server-sdk-common: 2.18.4</summary> ## [2.18.4](js-server-sdk-common-v2.18.3...js-server-sdk-common-v2.18.4) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-sdk-common bumped from 2.24.0 to 2.24.1 </details> <details><summary>js-server-sdk-common-edge: 2.6.17</summary> ## [2.6.17](js-server-sdk-common-edge-v2.6.16...js-server-sdk-common-edge-v2.6.17) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from 2.18.3 to 2.18.4 </details> <details><summary>node-server-sdk: 9.10.11</summary> ## [9.10.11](node-server-sdk-v9.10.10...node-server-sdk-v9.10.11) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from 2.18.3 to 2.18.4 </details> <details><summary>node-server-sdk-dynamodb: 6.2.23</summary> ## [6.2.23](node-server-sdk-dynamodb-v6.2.22...node-server-sdk-dynamodb-v6.2.23) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/node-server-sdk bumped from 9.10.10 to 9.10.11 * peerDependencies * @launchdarkly/node-server-sdk bumped from >=9.4.3 to >=9.10.11 </details> <details><summary>node-server-sdk-otel: 1.3.11</summary> ## [1.3.11](node-server-sdk-otel-v1.3.10...node-server-sdk-otel-v1.3.11) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/node-server-sdk bumped from 9.10.10 to 9.10.11 * peerDependencies * @launchdarkly/node-server-sdk bumped from >=9.4.3 to >=9.10.11 </details> <details><summary>node-server-sdk-redis: 4.2.23</summary> ## [4.2.23](node-server-sdk-redis-v4.2.22...node-server-sdk-redis-v4.2.23) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/node-server-sdk bumped from 9.10.10 to 9.10.11 * peerDependencies * @launchdarkly/node-server-sdk bumped from >=9.4.3 to >=9.10.11 </details> <details><summary>react-native-client-sdk: 10.15.2</summary> ## [10.15.2](react-native-client-sdk-v10.15.1...react-native-client-sdk-v10.15.2) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk-common bumped from 1.23.0 to 1.24.0 </details> <details><summary>react-sdk: 0.2.0</summary> ## [0.2.0](react-sdk-v0.1.1...react-sdk-v0.2.0) (2026-04-14) ### Features * adding isomorphic provider to bridge client and server ([#1218](#1218)) ([d766f39](d766f39)) * support static client component rendering ([#1227](#1227)) ([6b3a100](6b3a100)) ### Bug Fixes * adding wrapper name for react client ([#1199](#1199)) ([f92a8f9](f92a8f9)) * **deps:** update dependency next to v16.2.3 [security] ([#1263](#1263)) ([10f582a](10f582a)) * **react-sdk:** double evaluation on client side init ([#1229](#1229)) ([6a4c42f](6a4c42f)) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk bumped from ^4.4.1 to ^4.5.0 * @launchdarkly/js-server-sdk-common bumped from ^2.18.3 to ^2.18.4 </details> <details><summary>server-sdk-ai: 0.16.8</summary> ## [0.16.8](server-sdk-ai-v0.16.7...server-sdk-ai-v0.16.8) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/js-server-sdk-common bumped from 2.18.3 to 2.18.4 * peerDependencies * @launchdarkly/js-server-sdk-common bumped from 2.x to 2.18.4 </details> <details><summary>server-sdk-ai-langchain: 0.5.4</summary> ## [0.5.4](server-sdk-ai-langchain-v0.5.3...server-sdk-ai-langchain-v0.5.4) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/server-sdk-ai bumped from ^0.16.7 to ^0.16.8 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^0.15.0 || ^0.16.0 to ^0.16.8 </details> <details><summary>server-sdk-ai-openai: 0.5.4</summary> ## [0.5.4](server-sdk-ai-openai-v0.5.3...server-sdk-ai-openai-v0.5.4) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/js-server-sdk-common bumped from 2.18.3 to 2.18.4 * @launchdarkly/server-sdk-ai bumped from ^0.16.7 to ^0.16.8 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^0.15.0 || ^0.16.0 to ^0.16.8 </details> <details><summary>server-sdk-ai-vercel: 0.5.4</summary> ## [0.5.4](server-sdk-ai-vercel-v0.5.3...server-sdk-ai-vercel-v0.5.4) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/server-sdk-ai bumped from ^0.16.7 to ^0.16.8 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^0.15.0 || ^0.16.0 to ^0.16.8 </details> <details><summary>shopify-oxygen-sdk: 0.1.8</summary> ## [0.1.8](shopify-oxygen-sdk-v0.1.7...shopify-oxygen-sdk-v0.1.8) (2026-04-14) ### Bug Fixes * **shopify:** standardizing the pre-release banner ([#1268](#1268)) ([82adddb](82adddb)) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common bumped from 2.18.3 to 2.18.4 </details> <details><summary>vercel-server-sdk: 1.3.43</summary> ## [1.3.43](vercel-server-sdk-v1.3.42...vercel-server-sdk-v1.3.43) (2026-04-14) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-server-sdk-common-edge bumped from 2.6.16 to 2.6.17 </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Primarily automated version/changelog updates across many packages; the only functional change in-code is updating embedded SDK/version identifiers, which is low risk but could affect user-agent/wrapper reporting. > > **Overview** > Bumps versions and publishes release metadata across the monorepo (manifest, `package.json`s, and changelogs), including `js-client-sdk` `4.5.0`, `react-sdk` `0.2.0`, and multiple server/edge/provider packages. > > Updates embedded `x-release-please-version` constants used for SDK identification (e.g., `BrowserInfo`, `NodeInfo`, edge platform info) and updates the React client default `wrapperVersion` to `0.2.0` for telemetry/user-agent reporting. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a09a298. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>


Summary
FDv2DataManagerBase— shared data manager orchestrating FDv2 connection mode switching, state debouncing, and data source lifecycleDataManagerinterface with foreground/background mode support, forced/automatic streaming control, and flush callbacksFlagManager.applyChangesfrom feat: FlagManager.applyChanges for FDv2 full/partial/none semantics #1208 for full/partial/none flag update semanticsStacked on #1209 and #1208.
Note
Medium Risk
Adds a new shared FDv2 data manager that controls connection-mode resolution and data source lifecycle, plus updates public
dataSystemoption shapes; mistakes here could affect SDK initialization, reconnection behavior, and flag freshness across platforms.Overview
Introduces
createFDv2DataManagerBase(and exported types) as a shared FDv2 orchestration layer that performs mode resolution/debouncing, managesFDv2DataSourcecreation/teardown across identifies and mode changes, tracks selector state, triggers a background flush callback, and optionally appends a blocked FDv1 polling fallback synchronizer.Updates the public
dataSystemconfiguration model by renaminginitialConnectionModetoforegroundConnectionModein platform defaults and by makingautomaticModeSwitchinga discriminated union ({type:'automatic'}vs{type:'manual', initialConnectionMode}), with validator support viavalidatorOf(..., { is }); tests are updated and expanded accordingly, including a large new test suite forFDv2DataManagerBase.Written by Cursor Bugbot for commit 0786b64. This will update automatically on new commits. Configure here.