Skip to content
Merged
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
13 changes: 13 additions & 0 deletions src/wasp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,19 @@ export class WaSP extends EventEmitter {
status: 'DISCONNECTED' as SessionStatus,
});

// Evict from activeSessions so consumer can call createSession() to reconnect.
// Without this, transient drops (Baileys reason -1, 515, 503) leave a zombie
// entry that blocks reconnect with "Session already exists".
const entry = this.activeSessions.get(sessionId);
if (entry) {
try {
entry.provider.events.removeAllListeners();
} catch {
// listeners may already be detached; safe to ignore
}
this.activeSessions.delete(sessionId);
}

await this.emitEvent({
type: 'SESSION_DISCONNECTED' as EventType,
sessionId,
Expand Down
Loading