Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class DefaultBrowserEventSource implements LDEventSource {
// The event source may not produce a status. But the LaunchDarkly
// polyfill can. If we can get the status, then we should stop retrying
// on certain error codes.
if (err.status && typeof err.status === 'number' && !this._errorFilter(err)) {
if (typeof err.status === 'number' && !this._errorFilter(err)) {
// If we encounter an unrecoverable condition, then we do not want to
// retry anymore.
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ export function createStreamingBase(config: {
}

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.

if (eventName !== 'error') {
config.logger?.warn(`Event from EventStream missing data for "${eventName}".`);
}
return;
}

Expand Down Expand Up @@ -277,8 +280,18 @@ export function createStreamingBase(config: {
config.logger?.info('Closed LaunchDarkly stream connection');
};

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.

if (stopped) {
return;
}

if (err && typeof err.status === 'number') {
// This condition will be handled by the error filter.
return;
}
Comment thread
cursor[bot] marked this conversation as resolved.
resultQueue.put(
interrupted(errorInfoFromNetworkError(err?.message ?? 'IO Error'), fdv1Fallback),
);
Comment thread
cursor[bot] marked this conversation as resolved.
Comment thread
kinyoklion marked this conversation as resolved.
Comment thread
cursor[bot] marked this conversation as resolved.
};

es.onopen = () => {
Expand Down
Loading