"TypeError: error is undefined" inside onSocketError

It appears that it is possible for WebSocket connections to return a socket error without a payload, which causes onSocketError to throw.