websocket
websocket copied to clipboard
When Send is called on a closed WebSocket, no error returned.
The problem is already mentioned in code, see wrapper.go#L97-L98.
I can confirm the issue. Send returns nil error, but there is a WebSocket is already in CLOSING or CLOSED state. error in the console.

Any ideas on how we can fix this?
Just a dumb idea, but can we check the ReadyState value in Send?
Just a dumb idea, but can we check the
ReadyStatevalue inSend?
I don't see any technical reason that we couldn't. I wonder if there's a way that we could capture the exception and return it, though.
I wonder if there's a way that we could capture the exception and return it, though.
I agree that would be better. It's clean, correct, consistent, and doesn't incur an extra performance penalty every time sending on an open socket. I would only fall back to checking ReadyState as a backup, if we can't get anything else to work.