Open chekoopa opened 4 years ago
Ahh, okay shoot, sorry for not catching this. I think you may be right - socket.close :: Effect Unit
is just underlyingly calling socket.close()
in JavaScript, without socket.close(code,reason)
parameters - although, there is also an event listener attached to the "close"
event, that relays the call to socket.close()
after filing some of the parsed information.
It might take some playing, but I'll get this fixed hopefully this weekend. Does it happen with any socket you are trying to open? If not, would you be willing to provide a minimal example? Thank you again for catching this.
It doesn't matter close
or close'
was called. I suppose when this close
handler is called, the socket is closed already, thus this socket.close(e)
may be out of place. Moreover, the handler calls it with the Event object instead of proper (code, reason)
.
I can't provide you a truly minimal example, but here's my Websocket client using Flame framework just to experience this kind of error. Just build it with the latest package-set and browserify it with your usual tool. It can both show error on client-side disconnect (wss://echo.websocket.org
) and server-side handshake error (wss://libwebsockets.org/
)
https://gist.github.com/chekoopa/90b38915fb7beee49c9241b6a54cbc17
I'm running into this as well on Firefox and Linux.
If you're still interested in addressing this then I can work up a minimal example tomorrow.
Whenever
close
is called (no matter with or without optional data, on client side or server side, like handshake error), browser throws the async exception from this line. https://github.com/athanclark/purescript-websocket-moderate/blob/1694260626d5c92b8393c1f12c420ef7c202cb2d/src/WebSocket.js#L32The exception text is:
My guess is that this line isn't neccessary, or at least it should check readyState before calling.
Just for the record, I'm using v7.0.2. The browser is Chromuim 83.0.4103.61 (dev), (64-bit), NixOS Linux 20.09.