Skip to content

Commit 93b9081

Browse files
author
Bruno Sgarbi
committed
review: address Sourcery feedback — neutral language + log error object
Per #2520 review: 1. Drop vendor-specific markers in code comment and log message (was '[ZOMBIE-CLEANUP]' and 'RIGARR PATCH'). Comment now describes the bug in upstream-friendly terms. 2. Pass the full error object to logger.warn instead of toString(), following the existing convention in monitor.service.ts ('no.connection' handler) where structured object logging is used to preserve diagnostic detail. No behavior change.
1 parent 7e4f4a7 commit 93b9081

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

src/api/controllers/instance.controller.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,18 @@ export class InstanceController {
458458
if (instance.state === 'connecting' || instance.state === 'open') {
459459
try {
460460
await this.logout({ instanceName });
461-
} catch (logoutError) {
462-
// RIGARR PATCH: zombie instance cleanup.
463-
// When a Baileys socket is dead but waInstances[name] still exists,
464-
// logout() throws "Connection Closed". Without this catch, the
465-
// remove.instance emit below never runs, leaving the zombie in memory
466-
// forever (only fixable by restarting the entire container).
467-
this.logger.warn(
468-
`[ZOMBIE-CLEANUP] logout failed for "${instanceName}" (likely zombie socket): ${logoutError?.toString?.() || logoutError}. Proceeding with cleanup.`,
469-
);
461+
} catch (error) {
462+
// logout can throw "Connection Closed" when the underlying Baileys
463+
// socket is already dead but waInstances[name] still exists. We
464+
// must continue to the remove.instance emit below — that is the
465+
// only path that purges the in-memory entry and runs cleaningUp().
466+
// Without this catch, the stale entry persists until the entire
467+
// process restarts.
468+
this.logger.warn({
469+
message: 'logout failed during deleteInstance — proceeding with cleanup',
470+
instanceName,
471+
error,
472+
});
470473
}
471474
}
472475

0 commit comments

Comments
 (0)