Skip to content

feat: Thread FDv1 fallback TTL through polling and streaming data sources - #1806

Open
joker23 wants to merge 12 commits into
mainfrom
skz/SDK-2687/fdv1-fallback-fix-fallback-ttl-source-threading
Open

feat: Thread FDv1 fallback TTL through polling and streaming data sources#1806
joker23 wants to merge 12 commits into
mainfrom
skz/SDK-2687/fdv1-fallback-fix-fallback-ttl-source-threading

Conversation

@joker23

@joker23 joker23 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

This commit will add in fallback TTL reading support as well as allow RN native event source read headers.

NOTE: while working this PR, I found a lot of gaps in the RN eventsource. Internally tracked in ticket 2721 in sdk project.


Note

Medium Risk
Changes FDv2 data-source orchestration, selector lifetime, and when clients fall back to FDv1—behavior-critical paths with broad test coverage but real production impact if directives are misread.

Overview
Adds centralized FDv1 fallback directive parsing (x-ld-fd-fallback, x-ld-fd-fallback-ttl in seconds → ms, plus in-band protocolFallbackTTL on goodbye) and threads FallbackDirective through FDv2SourceResult helpers instead of a bare boolean.

Polling reads directives on every response; a goodbye paired with fallback is reported as terminal_error so the orchestrator switches off FDv2. Polling initializer skips retries when a recoverable error carries a fallback directive.

Streaming defers fallback from onopen headers until the next queued result (pendingFallback / resolveFallback / putWithFallback), merges deferred TTL into ping-triggered polls without mutating the poll result object, and clears committed/pending fallback on clean reconnect. Error, malformed JSON, ping failure, and error-filter paths can surface deferred fallback with TTL.

Orchestrator (FDv2DataSource) checks FDv1 fallback after all result handling so a transfer-none changeSet with fdv1Fallback: true stops the initializer chain. FDv2DataManagerBase no longer clears the selector when a none payload arrives (e.g. HTTP 304).

CI bumps @launchdarkly/js-client-sdk-common ESM size limit 39300 → 41500.

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

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 16, 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: 41308 bytes
Compressed size limit: 41500
Uncompressed size: 224012 bytes

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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

@joker23

joker23 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@cursor review

cursor[bot]

This comment was marked as resolved.

@joker23
joker23 force-pushed the skz/SDK-2687/fdv1-fallback-fix-fallback-ttl-source-threading branch from e4fa9cb to 1400310 Compare July 17, 2026 14:01
@joker23

joker23 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@cursor review

cursor[bot]

This comment was marked as resolved.

Comment thread packages/sdk/react-native/src/fromExternal/react-native-sse/EventSource.ts Outdated
Comment thread .github/workflows/sdk-client.yml Outdated
@joker23
joker23 force-pushed the skz/SDK-2687/fdv1-fallback-fix-fallback-ttl-source-threading branch from 46de8d4 to 6604149 Compare July 17, 2026 16:56
@joker23

joker23 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@cursor review

cursor[bot]

This comment was marked as resolved.

@joker23

joker23 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread packages/sdk/react-native/src/fromExternal/react-native-sse/EventSource.ts Outdated
cursor[bot]

This comment was marked as resolved.

Comment thread packages/sdk/react-native/src/fromExternal/react-native-sse/EventSource.ts Outdated
@joker23
joker23 force-pushed the skz/SDK-2687/fdv1-fallback-fix-fallback-ttl-source-threading branch from 29aefb7 to 73eeb30 Compare July 17, 2026 22:00
@joker23

joker23 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@cursor review

cursor[bot]

This comment was marked as resolved.

@joker23

joker23 commented Jul 20, 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 c01baaa. Configure here.

terminalError,
} from './FDv2SourceResult';

function getFallback(headers: { get(name: string): string | null }): boolean {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

replacing with

export function readFallbackDirective(headers: {

@joker23
joker23 marked this pull request as ready for review July 20, 2026 16:55
@joker23
joker23 requested a review from a team as a code owner July 20, 2026 16:55

@devin-ai-integration devin-ai-integration Bot left a comment

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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Comment thread packages/shared/sdk-client/src/datasource/fdv2/PollingBase.ts Outdated
Comment thread packages/shared/sdk-client/src/datasource/fdv2/StreamingFDv2Base.ts Outdated
Comment thread packages/shared/sdk-client/src/datasource/fdv2/StreamingFDv2Base.ts Outdated
Comment thread packages/shared/sdk-client/src/datasource/fdv2/StreamingFDv2Base.ts Outdated
Comment thread packages/shared/sdk-client/src/datasource/fdv2/StreamingFDv2Base.ts Outdated
Comment thread packages/shared/sdk-client/src/datasource/fdv2/StreamingFDv2Base.ts
cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@joker23
joker23 force-pushed the skz/SDK-2687/fdv1-fallback-fix-fallback-ttl-source-threading branch from e95c2f2 to 005c842 Compare July 22, 2026 15:16
devin-ai-integration[bot]

This comment was marked as resolved.

This will allow us to resolve directives that should override the
fallback behavior such as goodbye or error
@joker23
joker23 force-pushed the skz/SDK-2687/fdv1-fallback-fix-fallback-ttl-source-threading branch from 005c842 to adfcb4d Compare July 22, 2026 16:07
devin-ai-integration[bot]

This comment was marked as resolved.

@joker23
joker23 requested a review from tanderson-ld July 22, 2026 16:35
// Recoverable error: save it and retry if attempts remain
lastResult = result;

if (attempt < maxRetries) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should be checking the fallback before the retries.

@tanderson-ld

Copy link
Copy Markdown
Contributor

Probably makes sense to wait for @kinyoklion's review since he left a comment.

devin-ai-integration[bot]

This comment was marked as resolved.

@joker23
joker23 requested a review from kinyoklion August 6, 2026 19:21
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