fix(platform): properly handle websocket error events (#967)

This commit is contained in:
Andrey Lushnikov 2020-02-12 16:59:19 -08:00 committed by GitHub
parent fbce2908ad
commit d26f47bb3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -325,7 +325,7 @@ export class WebSocketTransport implements ConnectionTransport {
}) : new WebSocket(url)) as WebSocket;
this._connect = new Promise((fulfill, reject) => {
this._ws.addEventListener('open', () => fulfill());
this._ws.addEventListener('error', event => reject(new Error(event.toString())));
this._ws.addEventListener('error', event => reject(new Error('WebSocket error: ' + (event as ErrorEvent).message)));
});
// The 'ws' module in node sometimes sends us multiple messages in a single task.
// In Web, all IO callbacks (e.g. WebSocket callbacks)