From f9274e181e04460249cd385a24ce5f1ec85a838d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 5 Oct 2016 07:35:30 +0200 Subject: [PATCH] [fix] Fix issue with errors during WebSocket creation not being caught at all (#475) Fixes #474. --- lib/transports/websocket.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/transports/websocket.js b/lib/transports/websocket.js index 4e45a3a11..adcfd6cfb 100644 --- a/lib/transports/websocket.js +++ b/lib/transports/websocket.js @@ -96,7 +96,11 @@ WS.prototype.doOpen = function () { opts.headers = this.extraHeaders; } - this.ws = BrowserWebSocket ? new WebSocket(uri) : new WebSocket(uri, protocols, opts); + try { + this.ws = BrowserWebSocket ? new WebSocket(uri) : new WebSocket(uri, protocols, opts); + } catch (err) { + return this.emit('error', err) + } if (this.ws.binaryType === undefined) { this.supportsBinary = false;