You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because there is no status code, WebSocket defaults to status code 1005 - No Status Rcvd ("Indicates that no status code was provided even though one was expected."). Given that the close is expected, the status should be 1000 - Normal Closure. Otherwise the consumer might treat status other than 1000 as error state, which is incorrect.
The text was updated successfully, but these errors were encountered:
ncowama
changed the title
WebSocketSubject does not provide code on close, defaulting to code=1005
WebSocketSubject does not provide code on close
Oct 5, 2023
Describe the bug
When closing the socket as part of subscription teardown, the implementation calls
_socket.close()
:https://github.com/ReactiveX/rxjs/blob/7.8.1/src/internal/observable/dom/WebSocketSubject.ts#L380-L382
Because there is no status code, WebSocket defaults to status code 1005 - No Status Rcvd ("Indicates that no status code was provided even though one was expected."). Given that the
close
is expected, the status should be 1000 - Normal Closure. Otherwise the consumer might treat status other than 1000 as error state, which is incorrect.There is a related issue: #4087 with a proposed solution to call
.error({ code })
.It's possible to work around this with a side-effect calling
wsSubject.error({ code: 1000 })
, but it's not idealExpected behavior
socket
is closed with code=1000 when subscription is closed. Or a mechanism to define status code for thesocket.close
call.Reproduction code
Reproduction URL
https://stackblitz.com/edit/rxjs-i5b8xv?file=index.ts
Version
v7.8.1
Environment
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: