From 3c6edde1d61af6619dd0eedefd8e286de4ab0d4d Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Mon, 8 Nov 2021 13:22:25 +0530 Subject: [PATCH] fix: listen to all failure messages --- src/Socket/socket.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Socket/socket.ts b/src/Socket/socket.ts index ff2bc3a..ddedd35 100644 --- a/src/Socket/socket.ts +++ b/src/Socket/socket.ts @@ -471,9 +471,10 @@ export const makeSocket = ({ const statusCode = +(node.attrs.code || DisconnectReason.restartRequired) end(new Boom('Stream Errored', { statusCode, data: node })) }) - // logged out - ws.on('CB:failure,reason:401', () => { - end(new Boom('Logged Out', { statusCode: DisconnectReason.loggedOut })) + // stream fail, possible logout + ws.on('CB:failure', (node: BinaryNode) => { + const reason = +(node.attrs.reason || 500) + end(new Boom('Connection Failure', { statusCode: reason, data: node.attrs })) }) process.nextTick(() => { ev.emit('connection.update', { connection: 'connecting', receivedPendingNotifications: false, qr: undefined })