Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/internal/observable/dom/WebSocketSubject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,12 @@ export class WebSocketSubject<T> extends AnonymousSubject<T> {
const { deserializer } = this._config;
observer.next(deserializer!(e));
} catch (err) {
this._resetState();
observer.error(err);
if (socket && (socket.readyState === 1 || socket.readyState === 0)) {
// close the socket after the observer so additional WebSocket events do not race to end the observer
socket.close();
}
}
};
}
Expand Down