-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(webSocket): manage serializer throwing exceptions #7114
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can accept this PR as-is. There's clearly a bug, but we need to discuss what the correct behavior is.
In general, the WebSocketSubject should emit the error... but also it seems like we should close the socket with the proper code when that happens.
if (socket!.readyState === 1) { | ||
try { | ||
const { serializer } = this._config; | ||
socket!.send(serializer!(x!)); | ||
} catch (e) { | ||
this.destination!.error(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say the actual bug was here. We clearly have a handle to the wrong thing. 🤔
Related issue (if exists):
Fixes #7111
Description:
I see the behaviour of the serializer was not really specified, I added a couple of tests to cover it.
This is the solution that's less disruptive with the previous behaviour:
{ code, reason }
it won't be effected by this change: The socket will be closed with those parameters..next(
caller.I think all of this points are open for discussion though. A couple of questions:
.next(
, or should it be thrown on the observer? I think throwing them on.next(
makes more sense, because it lets the producer know there was an exception. The observer expects errors to come only from the websocket.