Skip to content

fix: Improve error handling for FDv2 streaming#1184

Merged
kinyoklion merged 5 commits into
mainfrom
rlamb/fdv2-streaming-error-handling
Mar 12, 2026
Merged

fix: Improve error handling for FDv2 streaming#1184
kinyoklion merged 5 commits into
mainfrom
rlamb/fdv2-streaming-error-handling

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Mar 12, 2026

Copy link
Copy Markdown
Member

BEGIN_COMMIT_OVERRIDE
fix: Improve error handling for FDv2 streaming
fix: Allow 0 status code to be handled by the streaming error filter.
END_COMMIT_OVERRIDE


Note

Medium Risk
Changes reconnection/error classification logic in the streaming data source, which could affect when clients retry vs surface interruptions. Risk is moderate because it impacts core connectivity behavior but is localized and guarded by existing error filters.

Overview
Improves streaming error handling so any numeric err.status (including 0) is routed through the EventSource errorFilter rather than being treated as a missing-status/network error.

Reduces noise and false failures by (1) not warning when FDv2 'error' events arrive without a body, and (2) only queuing a network interruption on es.onerror when no numeric HTTP status is present (letting the filter handle status-bearing errors).

Written by Cursor Bugbot for commit 28ac8cf. This will update automatically on new commits. Configure here.

const resultQueue = createAsyncQueue<FDv2SourceResult>();
const protocolHandler = internal.createProtocolHandler(
{ flagEval: processFlagEval },
{ 'flag-eval': processFlagEval },

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.

Another PR will make all the other instances uniformly 'flag-eval'.


if (!event?.data) {
config.logger?.warn(`Event from EventStream missing data for "${eventName}".`);
// Some events (e.g. 'error') may legitimately arrive without a body.

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.

When you have an event called 'error' that will listen to errors from the event source instead of of just messages.

@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: 25566 bytes
Compressed size limit: 26000
Uncompressed size: 125383 bytes

@github-actions

github-actions Bot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 24522 bytes
Compressed size limit: 25000
Uncompressed size: 84897 bytes

@github-actions

github-actions Bot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

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


es.onerror = () => {
// Error handling is done by errorFilter.
es.onerror = (err?: HttpErrorResponse) => {

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.

Errors without an http status code are handled in this path, and ones with one are handled in the error filter.

@github-actions

Copy link
Copy Markdown
Contributor

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

@kinyoklion kinyoklion marked this pull request as ready for review March 12, 2026 17:09
@kinyoklion kinyoklion requested a review from a team as a code owner March 12, 2026 17:09
Comment thread packages/shared/sdk-client/src/datasource/fdv2/StreamingFDv2Base.ts
Comment thread packages/shared/sdk-client/src/datasource/fdv2/StreamingFDv2Base.ts
Comment thread packages/shared/sdk-client/src/datasource/fdv2/StreamingFDv2Base.ts

@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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread packages/shared/sdk-client/src/datasource/fdv2/StreamingFDv2Base.ts
@kinyoklion kinyoklion merged commit d96b46b into main Mar 12, 2026
43 checks passed
@kinyoklion kinyoklion deleted the rlamb/fdv2-streaming-error-handling branch March 12, 2026 19:54
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