diff --git a/src/BingAIClient.js b/src/BingAIClient.js index 6aaef643..266660c4 100644 --- a/src/BingAIClient.js +++ b/src/BingAIClient.js @@ -77,7 +77,7 @@ export default class BingAIClient { } async createWebSocketConnection() { - return new Promise((resolve) => { + return new Promise((resolve, reject) => { let agent; if (this.options.proxy) { agent = new HttpsProxyAgent(this.options.proxy); @@ -85,6 +85,8 @@ export default class BingAIClient { const ws = new WebSocket('wss://sydney.bing.com/sydney/ChatHub', { agent }); + ws.on('error', err => reject(err)); + ws.on('open', () => { if (this.debug) { console.debug('performing handshake');