Skip to content

Commit

Permalink
fix(WebSocketSubject): Closes socket when closing socket subject obse…
Browse files Browse the repository at this point in the history
…rver (ReactiveX#5312)
  • Loading branch information
bever1337 committed Sep 29, 2022
1 parent afac3d5 commit b08e116
Showing 1 changed file with 5 additions and 0 deletions.
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

0 comments on commit b08e116

Please sign in to comment.