Skip to content

fix: Close FDv1 fallback and FDv2 recovery correctness gaps - #1875

Draft
joker23 wants to merge 4 commits into
skz/SDK-2912/fdv2-recovery-orchestration-recovery-timerfrom
skz/SDK-2912/fdv2-recovery-orchestration
Draft

fix: Close FDv1 fallback and FDv2 recovery correctness gaps#1875
joker23 wants to merge 4 commits into
skz/SDK-2912/fdv2-recovery-orchestration-recovery-timerfrom
skz/SDK-2912/fdv2-recovery-orchestration

Conversation

@joker23

@joker23 joker23 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

NOTE: stacked on top of #1982

Summary

Four fixes found reviewing the recovery-timer PR in this stack, before they shipped:

  • Adds the missing "10s uninitialized" leg to the FDv2 fallback condition group: before the data system has ever received data, a source that hangs without producing interrupted or a changeSet now still triggers fallback after initFallbackTimeoutMs (default 10s), complementing the existing interrupted-based leg.
  • Fixes a starvation bug where a repeated fallback directive from a source that never transitions off FDv2 (no FDv1 synchronizer configured) kept re-arming the recovery deadline, so it could never elapse. Now only the first directive per engagement re-arms it.
  • Fixes a 'none'-payload changeSet incorrectly marking the data system initialized, and adds hasExistingData so a post-connection-mode-switch 'none' response on an already-initialized system doesn't churn through synchronizers looking for data that was never going to come.
  • Fixes a resource leak where SourceManager left the active source open when every synchronizer slot was blocked.

Note

Overview
Tightens FDv2 data-source orchestration around fallback conditions, FDv1 directives, and what counts as “initialized.”

Uninitialized fallback (10s leg): Before the data system has ever received real data, synchronizer fallback now includes an init-fallback timer (createInitFallbackCondition, default 10s) that fires even when the source never reports interrupted—so a hung primary can still move to the next synchronizer. Real changeSets cancel it; none payloads do not. getConditions takes an initialized flag and initFallbackTimeoutMs; FDv2DataSource wires hasExistingData so connection-mode rebuilds skip this leg.

Initialization semantics: Synchronizer-phase handling no longer calls markInitialized() on type: 'none' changeSets unless hasExistingData is set (manager passes prior initialized on rebuild). That stops empty poll/304 responses from falsely completing start() or disarming the init-fallback leg.

FDv1 fallback without an FDv1 slot: handleFdv1Fallback now always halts the current run via sourceManager.fdv1Fallback() when synchronizers exist (sets INTERRUPTED if no FDv1 slot), instead of ignoring the directive. Recovery TTL is scheduled only once per engagement—repeated directives from a still-running FDv2 source no longer reset the deadline and starve return to FDv2.

Resource cleanup: SourceManager closes the active synchronizer when every slot is blocked, so transports are not left running during recovery.

Tests cover the new conditions, orchestration paths, and a dedicated FDv1FallbackRecovery.test.ts.

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

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Aug 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: 32997 bytes
Compressed size limit: 34000
Uncompressed size: 118097 bytes

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Aug 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: 25884 bytes
Compressed size limit: 44000
Uncompressed size: 169247 bytes

@joker23
joker23 force-pushed the skz/sdk-2617/fdv1-fallback-fix branch from 8a0e71d to 698aa3f Compare August 25, 2026 15:11
@joker23
joker23 force-pushed the skz/SDK-2912/fdv2-recovery-orchestration branch from 2b280eb to 29566d1 Compare August 25, 2026 15:11
@joker23
joker23 force-pushed the skz/sdk-2617/fdv1-fallback-fix branch 2 times, most recently from 276e94f to 18ce666 Compare August 25, 2026 17:19
@joker23
joker23 force-pushed the skz/SDK-2912/fdv2-recovery-orchestration branch 3 times, most recently from e2afce4 to bee9b26 Compare August 25, 2026 19:33
Base automatically changed from skz/sdk-2617/fdv1-fallback-fix to main August 26, 2026 14:56
@joker23
joker23 force-pushed the skz/SDK-2912/fdv2-recovery-orchestration branch 4 times, most recently from aac69f6 to 8c8b2bc Compare August 28, 2026 14:52
@joker23

joker23 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

@cursor 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 8c8b2bc. Configure here.

@joker23
joker23 force-pushed the skz/SDK-2912/fdv2-recovery-orchestration branch from ba8623e to 36ba320 Compare August 31, 2026 19:23
@joker23
joker23 force-pushed the skz/SDK-2912/fdv2-recovery-orchestration branch from 36ba320 to a7a5773 Compare September 2, 2026 22:30
@joker23 joker23 changed the title feat: Schedule FDv2 recovery after the FDv1 fallback TTL elapses fix: Close FDv1 fallback and FDv2 recovery correctness gaps Sep 2, 2026
@joker23
joker23 changed the base branch from main to skz/SDK-2912/fdv2-recovery-orchestration-recovery-timer September 2, 2026 22:35
@joker23

joker23 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@cursor 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 a7a5773. Configure here.

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.

1 participant