Skip to content

fix: Close the final initializer on exhaustion; document the source manager contract#304

Merged
kinyoklion merged 1 commit into
mainfrom
rlamb/sdk-2186/fdv2-source-manager-fixes
Jun 12, 2026
Merged

fix: Close the final initializer on exhaustion; document the source manager contract#304
kinyoklion merged 1 commit into
mainfrom
rlamb/sdk-2186/fdv2-source-manager-fixes

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Jun 11, 2026

Copy link
Copy Markdown
Member

What this changes

Two small behavior hardenings and an explicit statement of the source manager's API contract.

  • Initializer exhaustion closes the final initializer. Every other transition closes the previous source when the next one is activated, but the exhaustion path returned null with the last initializer still active. When no synchronizer activation follows, that initializer (and its HTTP client) was held until shutdown. A terminal null now leaves no source running.
  • engageFdv1Fallback() is a no-op when no FDv1 fallback slot is configured. Blocking every slot without unblocking a fallback would leave nothing to activate. The orchestration layer checks before engaging; the guard makes the operation safe regardless of the caller.
  • hasFdv1FallbackConfigured replaces hasFdv1Fallback to make clear it reports configuration, not engagement state.

The documented contract

The class docs now state the assumptions the manager operates under, so they are visible at the API surface rather than implicit in the call sites:

  • The manager assumes a single, sequential driver. At most one source is active at a time: activating a source closes the previous one, exhaustion closes the final initializer, and close closes whatever remains.
  • The synchronizer scan cursor doubles as the active-slot pointer. From an activation (nextAvailableSynchronizer / recreateCurrentSynchronizer) until the next cursor mutation (resetSynchronizerIndex / engageFdv1Fallback), the cursor identifies the running synchronizer's slot — isPrimarySynchronizer and blockCurrentSynchronizer read it and are only meaningful inside that window. After mutating the cursor, a new synchronizer must be activated before consulting either. The driver satisfies this by construction: both reads happen strictly between an activation and the run's outcome being decided, and cursor mutations happen only after the outcome is decided.

Testing

New tests pin the exhaustion close (a terminal null leaves no source running) and the fallback-engagement guard (engaging with no configured FDv1 slot leaves the slot list untouched). Full package suite passes.

SDK-2186

@kinyoklion kinyoklion marked this pull request as ready for review June 12, 2026 16:32
@kinyoklion kinyoklion requested a review from a team as a code owner June 12, 2026 16:32
@kinyoklion kinyoklion marked this pull request as draft June 12, 2026 20:30
@kinyoklion kinyoklion force-pushed the rlamb/sdk-2186/fdv2-source-manager-fixes branch from d7b99a0 to f0e7b5c Compare June 12, 2026 20:30
@kinyoklion kinyoklion changed the title fix: Separate the FDv2 source manager scan cursor from the active slot fix: Close the final initializer on exhaustion; document the source manager contract Jun 12, 2026
/// activate. The active source keeps running until the next
/// activation closes it.
void engageFdv1Fallback() {
if (!hasFdv1FallbackConfigured) {

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.

In practice we may not make this possible.

@kinyoklion kinyoklion marked this pull request as ready for review June 12, 2026 20:42
@kinyoklion kinyoklion merged commit b20c35e into main Jun 12, 2026
6 checks passed
@kinyoklion kinyoklion deleted the rlamb/sdk-2186/fdv2-source-manager-fixes branch June 12, 2026 21:00
kinyoklion pushed a commit that referenced this pull request Jun 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.14.0](launchdarkly_common_client-v1.13.0...launchdarkly_common_client-v1.14.0)
(2026-06-29)


### Features

* add an initial connection mode to the FDv2 data system config
([#318](#318))
([5b980ab](5b980ab))
* Add FDv2 payload application via FlagManager.applyChanges
([#299](#299))
([66c2554](66c2554))
* Add FDv2 payload handling to the data source event handler
([#305](#305))
([761ed9d](761ed9d))
* Add FDv2 source manager
([#298](#298))
([43d899e](43d899e))
* Add FDv2 streaming source factories and query-parameter authentication
([7b46ac6](7b46ac6))
* Add FDv2 synchronizer fallback and recovery conditions
([#297](#297))
([17f7b4e](17f7b4e))
* Add the FDv2 data source orchestrator
([#307](#307))
([eb9a35f](eb9a35f))
* Add the FDv2 data system and expose it through configuration
([#310](#310))
([61a1e59](61a1e59))
* Centralize platform credential handling in CredentialConfig
([#300](#300))
([c677c3d](c677c3d))
* honor the FDv1 fallback directive on success, error, and goodbye
([#312](#312))
([1c35867](1c35867))
* Translate FDv2 payloads at the data source layer
([7b46ac6](7b46ac6))
* Update launchdarkly_event_source_client to version 2.2.0
([#302](#302))
([cb6a5c0](cb6a5c0))
* Update launchdarkly_event_source_client to version 3.0.0
([#317](#317))
([15861f8](15861f8))


### Bug Fixes

* Close the final initializer on exhaustion; document the source manager
contract
([#304](#304))
([b20c35e](b20c35e))

---
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**
> Version and changelog metadata only; no application logic changes in
the diff.
> 
> **Overview**
> Release Please bumps **`launchdarkly_common_client`** from **1.13.0**
to **1.14.0** with no runtime code changes in this PR.
> 
> Updates **`.release-please-manifest.json`**,
**`packages/common_client/pubspec.yaml`**, and adds a **1.14.0** section
to **`CHANGELOG.md`** that documents the FDv2 data system work,
credential centralization, event-source client upgrades, and related
fixes already merged on main.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
458f0b6. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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