fix: pass loggedOut reason in closeAll to prevent reconnect timers after shutdown
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user