fix: pass loggedOut reason in closeAll to prevent reconnect timers after shutdown

This commit is contained in:
2026-05-27 17:38:37 +05:30
parent 41aabc4c0d
commit 06449acd96
+3 -2
View File
@@ -1,4 +1,5 @@
import { WASocket } from '@whiskeysockets/baileys';
import { WASocket, DisconnectReason } from '@whiskeysockets/baileys';
import { Boom } from '@hapi/boom';
import { NormalizedMessage, NormalizedReaction } from '@tower/types';
import { createWhatsAppSession } from './session';
import { createLogger } from '@tower/logger';
@@ -66,7 +67,7 @@ export class WhatsAppSessionPool {
logger.info({ count: this.sessions.size }, 'Closing all WhatsApp sessions');
for (const [accountId, sock] of this.sessions) {
try {
sock.end(undefined);
sock.end(new Boom('Shutdown', { statusCode: DisconnectReason.loggedOut }));
logger.info({ accountId }, 'Session closed');
} catch (err) {
logger.error({ accountId, err }, 'Error closing session');