Skip to content

Prevent duplicate WhatsApp sockets during reconnects #10

Description

@cubrift

Problem

When the Baileys connection closes, index.js calls startBot() immediately. There is no reconnect guard or in-flight state, so repeated close events can start multiple sockets at the same time. Multiple sockets may compete for the same auth files, QR server, and message events.

Expected behavior

A disconnect should result in one controlled reconnect attempt for the bot.

Suggested direction

Track whether a reconnect is already running, or centralize socket creation behind a small reconnect loop. Preserve the logged-out behavior that asks whether the auth directory should be deleted.

Acceptance criteria

  • Repeated close events do not create overlapping sockets.
  • A normal transient disconnect still reconnects automatically.
  • Logged-out sessions retain the existing prompt and cleanup behavior.
  • The reconnect state is reset after a successful connection or a terminal logout.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcodexUse for codex-generated issues only.good first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions