Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/api/controllers/instance.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,21 @@ export class InstanceController {
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED) waInstances?.clearCacheChatwoot();

if (instance.state === 'connecting' || instance.state === 'open') {
await this.logout({ instanceName });
try {
await this.logout({ instanceName });
} catch (error) {
// logout can throw "Connection Closed" when the underlying Baileys
// socket is already dead but waInstances[name] still exists. We
// must continue to the remove.instance emit below — that is the
// only path that purges the in-memory entry and runs cleaningUp().
// Without this catch, the stale entry persists until the entire
// process restarts.
this.logger.warn({
message: 'logout failed during deleteInstance — proceeding with cleanup',
instanceName,
error,
});
}
}

try {
Expand Down