Skip to content

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