Skip to content

Fix: Initial messages could be lost #21

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

joshkel
Copy link
Contributor

@joshkel joshkel commented Sep 12, 2022

The use of await when handling the "initially" WebSocket message may cause incoming messages to be lost. Event handlers like ws.on('message', ...) may not get installed until after the asynchronous method completes, so any WebSocket events during that time period aren't handled.

Fixes #20

The use of await when handling the "initially" WebSocket message may cause incoming messages to be lost. Event handlers like `ws.on('message', ...)` may not get installed until after the asynchronous method completes, so any WebSocket events during that time period aren't handled.

Fixes rse#20
@rse
Copy link
Owner

rse commented Apr 27, 2023

Yes, correct: the "await" for the initial injected HTTP message might need more time than the arrival of the first Websocket message. But the solution is not such easy as to just use a promise callback instead, because the authorization has to be checked by the initial simulated HTTP request before a Websocket message should be processed. I've to look what the more correct solution is to resolve your issue and NOT cause a security issue.

WebSocket messages should not be processed until `initially` has finished and has a chance to optionally close the connection completely.

Disconnects and protocol-level errors are processed regardless - these occur at a lower level and should be preserved for consistency with connects.
@joshkel
Copy link
Contributor Author

joshkel commented May 7, 2023

@rse Thank you for pointing that out. I just pushed a potential fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initial messages may be lost
2 participants