From 4b802391306947165f36eb2883c272280b127a93 Mon Sep 17 00:00:00 2001 From: VerasV4 Date: Tue, 3 Feb 2026 10:50:04 -0300 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20Ajustando=20whatsapp.bailey.service.?= =?UTF-8?q?ts=20para=20mostrar=20corretamente=20o=20QR=20Code=20que=20n?= =?UTF-8?q?=C3=A3o=20estava=20aparecendo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../channel/whatsapp/whatsapp.baileys.service.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index 60e857fcc..955ee9a46 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -427,6 +427,15 @@ export class BaileysStartupService extends ChannelStartupService { const statusCode = (lastDisconnect?.error as Boom)?.output?.statusCode; const codesToNotReconnect = [DisconnectReason.loggedOut, DisconnectReason.forbidden, 402, 406]; const shouldReconnect = !codesToNotReconnect.includes(statusCode); + + // Check if this is the initial connection before QR code generation + const isInitialConnection = !this.instance.wuid && this.instance.qrcode.count === 0; + + if (isInitialConnection) { + this.logger.info('Initial connection closed, waiting for QR code generation...'); + return; // Prevents infinite reconnection loop + } + if (shouldReconnect) { await this.connectToWhatsapp(this.phoneNumber); } else { From a75cdf2c1436f2faf0c0ceb8cf192e8c6be8d1b9 Mon Sep 17 00:00:00 2001 From: VerasV4 Date: Tue, 3 Feb 2026 10:58:55 -0300 Subject: [PATCH 2/2] fix: applying sourcery-ai suggestion for safe access --- .../integrations/channel/whatsapp/whatsapp.baileys.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index 955ee9a46..2090ea6bf 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -429,7 +429,7 @@ export class BaileysStartupService extends ChannelStartupService { const shouldReconnect = !codesToNotReconnect.includes(statusCode); // Check if this is the initial connection before QR code generation - const isInitialConnection = !this.instance.wuid && this.instance.qrcode.count === 0; + const isInitialConnection = !this.instance.wuid && (this.instance.qrcode?.count ?? 0) === 0; if (isInitialConnection) { this.logger.info('Initial connection closed, waiting for QR code generation...');