Skip to content

Commit f9274e1

Browse files
Andaristdarrachequesne
authored andcommitted
[fix] Fix issue with errors during WebSocket creation not being caught at all (#475)
Fixes #474.
1 parent ea29487 commit f9274e1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/transports/websocket.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ WS.prototype.doOpen = function () {
9696
opts.headers = this.extraHeaders;
9797
}
9898

99-
this.ws = BrowserWebSocket ? new WebSocket(uri) : new WebSocket(uri, protocols, opts);
99+
try {
100+
this.ws = BrowserWebSocket ? new WebSocket(uri) : new WebSocket(uri, protocols, opts);
101+
} catch (err) {
102+
return this.emit('error', err)
103+
}
100104

101105
if (this.ws.binaryType === undefined) {
102106
this.supportsBinary = false;

0 commit comments

Comments
 (0)