From ba3cbd476ebdeaf52b7cb919cfc34eb6e5995513 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Thu, 24 Mar 2022 10:13:57 +0530 Subject: [PATCH] fix: correctly clear qrTimer --- src/Socket/socket.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Socket/socket.ts b/src/Socket/socket.ts index ba60c54..db06688 100644 --- a/src/Socket/socket.ts +++ b/src/Socket/socket.ts @@ -296,7 +296,7 @@ export const makeSocket = ({ logger.info({ error }, 'connection closed') clearInterval(keepAliveReq) - clearInterval(qrTimer) + clearTimeout(qrTimer) ws.removeAllListeners('close') ws.removeAllListeners('error') @@ -450,6 +450,10 @@ export const makeSocket = ({ let qrMs = 60_000 // time to let a QR live const genPairQR = () => { + if(ws.readyState !== ws.OPEN) { + return + } + const ref = refs.shift() if(!ref) { end(new Boom('QR refs attempts ended', { statusCode: DisconnectReason.timedOut }))