hapi-plugin-websocket
hapi-plugin-websocket copied to clipboard
Fix: Initial messages could be lost
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
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.
@rse Thank you for pointing that out. I just pushed a potential fix.