Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix: WebSocket Duplex Connection Unhandled Exceptions #278

Open
wants to merge 1 commit into
base: 1.0.x-alpha
Choose a base branch
from

Conversation

stevensJourney
Copy link

This fixes some potential unhandled exceptions in rsocket-websocket-server relating to the underlying WebSocket readyState and deserialisation of invalid frames.

Motivation:

I've noticed intermittent unhandled exceptions for the errors below:

WebSocket is in CLOSING state:
image

Unable to read type of undefined frame:
image

Modifications:

WebSocket readyState

The WebSocket from the ws library is now used to check the readyState before calling write on the Duplex stream.

Undefined frame:

I believe this error was caused by the deserializeFrame method returning undefined. This could be verified by a client connecting to the server WebSocket port and sending a random Buffer payload.

The connection will now close if no valid frame could be deserialised.

Result:

The external API and behaviour should be the same as before. There should now be less potential for unhandled exceptions.

Side Note:

I've noticed some formatting changes were included here. Is there perhaps a Prettier config I could use? Running yarn lint on my machine also shows errors for other package's files. Perhaps this is somehow linking to external settings I might have. Please advise.

…or CLOSED. WebSocketDuplex connection should handle invalid frames.

Signed-off-by: Steven Ontong <steven@journeyapps.com>
@stevensJourney stevensJourney force-pushed the fix/websocket-duplex-connections branch from 4aecb92 to ca22c35 Compare June 11, 2024 09:39
@viglucci viglucci added 1.0 Pullrequests & issues related to the Typescript rewrite and 1.0 release needs triage Issue/PR needs triage by a project maintainer labels Jun 14, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
1.0 Pullrequests & issues related to the Typescript rewrite and 1.0 release needs triage Issue/PR needs triage by a project maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants