Skip to content

fix: FDv2 Only -- Adjust the behavior of initialization when only cache initializers are available.#1304

Merged
kinyoklion merged 6 commits into
mainfrom
rlamb/cache-initializer-offline-adjustments
Apr 23, 2026
Merged

fix: FDv2 Only -- Adjust the behavior of initialization when only cache initializers are available.#1304
kinyoklion merged 6 commits into
mainfrom
rlamb/cache-initializer-offline-adjustments

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Apr 21, 2026

Copy link
Copy Markdown
Member

The main goal of this is to attach meta-data to cache initializer factories to allow for making some additional runtime decisions with regard to initialization.

In doing so I am changing the factory types from functions into an interface. Which will make this kind of change easier in the future. So the majority of actual change is from that adjustment.


Note

Medium Risk
Touches FDv2 data-source orchestration and factory typings; mistakes could change initialization resolution/rejection and status reporting (especially offline/cache-only scenarios). Scope is contained to FDv2 pipeline and is covered by expanded tests.

Overview
FDv2 initialization now treats cache-only configurations as valid even on cache miss. FDv2DataSource detects when all initializers are cache-marked and there are no synchronizers, and in that case resolves initialization (optionally asserting VALID) instead of rejecting with “all sources exhausted”; it also avoids overwriting previously-reported error status and guards against close() races during the exhaustion path.

Factory types were refactored from function types to { create(...) } interfaces (InitializerFactory adds optional isCache), requiring updates across SourceManager, SourceFactoryProvider, FDv2DataManagerBase (FDv1 fallback factory), and tests; createCacheInitializerFactory now returns an isCache-marked factory. CI package-size threshold was bumped from 38000 to 39000.

Reviewed by Cursor Bugbot for commit 1104dc5. Bugbot is set up for automated code reviews on this repo. Configure here.

@kinyoklion kinyoklion force-pushed the rlamb/cache-initializer-offline-adjustments branch from 524af8c to 48c192d Compare April 21, 2026 23:14
@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: 25623 bytes
Compressed size limit: 29000
Uncompressed size: 125843 bytes

@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

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

@kinyoklion kinyoklion force-pushed the rlamb/cache-initializer-offline-adjustments branch from 48c192d to 4d6b1c2 Compare April 21, 2026 23:19

// All initializers exhausted.
if (dataReceived) {
if (dataReceived || cacheOnlyDataSystem) {

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.

Everything is basically to accomplish this.

@kinyoklion

Copy link
Copy Markdown
Member Author

bugbot review

Comment thread packages/shared/sdk-client/src/datasource/fdv2/FDv2DataSource.ts Outdated
Split the end-of-chain branch in the FDv2 orchestrator so VALID is only
requested for the cache-only-data-system case. When data was received
from an earlier initializer and a later one errored, the combined branch
was overwriting the reported error status back to VALID. Adds a
regression test that fails under the old conflated branch.
@kinyoklion

Copy link
Copy Markdown
Member Author

bugbot review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3e9be10. Configure here.

Add a !dataReceived guard inside the cacheOnlyDataSystem exhaustion
branch so a cache hit does not request VALID twice (applyChangeSet
already drove it). Adds a boundary test that locks the mixed-chain
behavior: a cache initializer followed by a non-cache initializer
where neither delivers data must NOT complete initialization, because
cacheOnlyDataSystem is false.
Two subtle bugs in the cache-only exhaustion branch:

1. Close race: if close() runs before runInitializers starts, the loop
   was skipped entirely and the exhaustion branch fired VALID and marked
   the start() promise resolved, where it should reject with "closed
   before initialization completed." Add an early return when closed is
   set before the exhaustion branch.

2. VALID-over-error: the branch unconditionally requested VALID on cache
   miss. Today's default CacheInitializer never emits error statuses, but
   a custom cache-marked factory could. Track errorReportedDuringInit
   from the interrupted/terminal_error cases and skip the VALID request
   when an error was reported.

Adds regression tests for both paths: close-before-init rejects and
emits no VALID, and a cache-only factory emitting interrupted leaves
the error status intact.
@kinyoklion

Copy link
Copy Markdown
Member Author

bugbot review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 1104dc5. Configure here.

@kinyoklion kinyoklion marked this pull request as ready for review April 22, 2026 22:20
@kinyoklion kinyoklion requested a review from a team as a code owner April 22, 2026 22:20
Comment thread packages/shared/sdk-client/src/datasource/fdv2/FDv2DataSource.ts
@kinyoklion kinyoklion merged commit 9a2b25a into main Apr 23, 2026
45 checks passed
@kinyoklion kinyoklion deleted the rlamb/cache-initializer-offline-adjustments branch April 23, 2026 16:42
@github-actions github-actions Bot mentioned this pull request Apr 23, 2026
joker23 pushed a commit that referenced this pull request Apr 23, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>browser: 0.1.17</summary>

##
[0.1.17](browser-v0.1.16...browser-v0.1.17)
(2026-04-23)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk bumped from 4.6.1 to 4.6.2
</details>

<details><summary>browser-telemetry: 1.0.33</summary>

##
[1.0.33](browser-telemetry-v1.0.32...browser-telemetry-v1.0.33)
(2026-04-23)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/js-client-sdk bumped from 4.6.1 to 4.6.2
</details>

<details><summary>jest: 1.0.11</summary>

##
[1.0.11](jest-v1.0.10...jest-v1.0.11)
(2026-04-23)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/react-native-client-sdk bumped from ~10.16.0 to ~10.17.0
</details>

<details><summary>js-client-sdk: 4.6.2</summary>

##
[4.6.2](js-client-sdk-v4.6.1...js-client-sdk-v4.6.2)
(2026-04-23)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 1.25.0 to 1.26.0
</details>

<details><summary>js-client-sdk-common: 1.26.0</summary>

##
[1.26.0](js-client-sdk-common-v1.25.0...js-client-sdk-common-v1.26.0)
(2026-04-23)


### Features

* support waitForNetworkResults in FDv2 data manager
([#1280](#1280))
([df7fa9e](df7fa9e))


### Bug Fixes

* FDv2 Only -- Adjust the behavior of initialization when only cache
initializers are available.
([#1304](#1304))
([9a2b25a](9a2b25a))
* migrate anonymous context namespace to general namespace
([#1312](#1312))
([afbed0f](afbed0f))
</details>

<details><summary>node-server-sdk-dynamodb: 6.2.24</summary>

##
[6.2.24](node-server-sdk-dynamodb-v6.2.23...node-server-sdk-dynamodb-v6.2.24)
(2026-04-23)


### Bug Fixes

* **node-server-sdk-dynamodb:** remove unnecessary ioredis package
([#1306](#1306))
([5d6c86e](5d6c86e))
</details>

<details><summary>react-native-client-sdk: 10.17.0</summary>

##
[10.17.0](react-native-client-sdk-v10.16.0...react-native-client-sdk-v10.17.0)
(2026-04-23)


### Features

* **react-native:** no storage fallback to in-memory map
([#1281](#1281))
([cc86eab](cc86eab))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 1.25.0 to 1.26.0
</details>

<details><summary>react-sdk: 0.2.3</summary>

##
[0.2.3](react-sdk-v0.2.2...react-sdk-v0.2.3)
(2026-04-23)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk bumped from ^4.6.1 to ^4.6.2
</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 a Release Please version bump across multiple packages with
dependency updates; only minimal runtime impact beyond consuming the new
`@launchdarkly/js-client-sdk-common` behavior changes pulled in by the
bumps.
> 
> **Overview**
> **Release automation update:** bumps workspace package versions and
changelogs for a coordinated release.
> 
> Updates `@launchdarkly/js-client-sdk` to `4.6.2` (and consumers
`@launchdarkly/browser`, `@launchdarkly/react-sdk`, and examples) plus
`@launchdarkly/js-client-sdk-common` to `1.26.0`. Also bumps
`@launchdarkly/react-native-client-sdk` to `10.17.0` (and
`@launchdarkly/jest` dependency), `@launchdarkly/browser-telemetry` to
`1.0.33`, and `@launchdarkly/node-server-sdk-dynamodb` to `6.2.24`,
along with manifest updates and wrapper/version constants.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
9c1a764. 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>
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.

3 participants