fix: Improve error handling for FDv2 streaming#1184
Conversation
| const resultQueue = createAsyncQueue<FDv2SourceResult>(); | ||
| const protocolHandler = internal.createProtocolHandler( | ||
| { flagEval: processFlagEval }, | ||
| { 'flag-eval': processFlagEval }, |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
When you have an event called 'error' that will listen to errors from the event source instead of of just messages.
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/browser size report |
|
|
||
| es.onerror = () => { | ||
| // Error handling is done by errorFilter. | ||
| es.onerror = (err?: HttpErrorResponse) => { |
There was a problem hiding this comment.
Errors without an http status code are handled in this path, and ones with one are handled in the error filter.
|
@launchdarkly/js-client-sdk-common size report |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

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(including0) is routed through the EventSourceerrorFilterrather 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 ones.onerrorwhen 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.