-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebSocket: Connection not closed when sole Subscription isStopped after an error #5312
Comments
I hit the same problem. any help on this one, folks ? |
I think i am facing same issue! Any solution? In dev window i still see that specific WS connection shown as 101 but not Finished even though i close the WebSocketSubject or do complete() call on it. |
any news? |
Hey, @kwonoj 👋 I've noticed the issue you've created and pinned earlier this year, #5970. I was wondering if this is somehow related to why there are no responses to this issue. Should I create a new discussion and link this? I'm not sure, as it can be interpreted as both |
This is a really interesting bug, and I can imagine why there's been no traction. In this case, there's no error with the underlying WebSocket, but there is an error during de-serialization. Removing RxJS from the equation, throwing an error during an I think the side-effect of fixing this bug is that some users may have already found a solution to intentionally unsubscribe from the subject and close the socket. In my experience, redundant calls to unsubscribe are a non-issue. |
The websocket is closed when there are no more observers. When there is a JSON parsing error, all observers unsubscribe, resulting in the websocket closing. I tested this on v7.5.5 (demo here) and it seems to work fine (note demo websocket API key only lasts a week). Has this issue already been fixed? Or can someone modify the demo above to reproduce the websocket not closing issue? |
As we worked around this, I never got around to rechecking this. But better late than never I suppose 😅 I've upgraded RxJS to the latest version, |
Bug Report
Current Behavior
When sole
WebSocketSubject
Subscription
encounters an error, itisStopped
and no longer handles anything, but the underlying connection is not closed.Reproduction
Source: rxjs-ws-error-handling-test.zip
node
andnpm
installed. I've used versions12.15.0
and6.13.7
respectively.npm install
node server.js
index.html
is served vialocalhost
. I've used Python 3:python3 -m http.server 1234
http://localhost:1234/
WebSocketSubject
'sopenObserver
handler called).Subscription
'snext
handler called).Subscription
'serror
handler called). TheSubscription
is now stopped, but the WebSocket connection remains opened (DevTools > Network > WS).Subscription
'snext
handler is NOT called.WebSocketSubject
'scloseObserver
handler called).Expected behavior
If all of a
WebSocketSubject
's Subscriptions are stopped / closed, I believe the connection should also close.Environment
The text was updated successfully, but these errors were encountered: