Skip to content

Commit

Permalink
refactor: update onNotification.js to handle WebSocket creation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Prioq committed Oct 21, 2024
1 parent 5538bac commit a2c987d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/client/onNotification.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ exports.func = function (args) {
options.agent = proxyAgent;
}

ws = new WebSocket(url, [], options);
try {
ws = new WebSocket(url, [], options);

} catch (err) {
notifications.emit('error', new Error('Failed to create WebSocket: ' + err.message));
return;
}

ws.on('open', () => {
retryCount = 0;
Expand Down

0 comments on commit a2c987d

Please sign in to comment.