Skip to content

Use whatsmeow auto-reconnect exclusively - #5

Open
pingrishabh wants to merge 1 commit into
mitensampat:mainfrom
pingrishabh:agent/use-whatsmeow-auto-reconnect
Open

Use whatsmeow auto-reconnect exclusively#5
pingrishabh wants to merge 1 commit into
mitensampat:mainfrom
pingrishabh:agent/use-whatsmeow-auto-reconnect

Conversation

@pingrishabh

Copy link
Copy Markdown

What changed

  • make whatsmeow the sole owner of authenticated socket reconnection
  • bind whatsmeow's background reconnect lifecycle to the application context
  • remove the competing application-level reconnect loop from events.Disconnected
  • add lifecycle tests for reconnect configuration and connection-state updates

Why

whatsmeow.NewClient enables EnableAutoReconnect by default. The existing events.Disconnected handler also launched its own exponential-backoff loop and called Connect, so a disconnect could create two concurrent reconnect owners racing on the same client.

Connection events now only update application state. Ordinary reconnects are handled by whatsmeow, while application shutdown cancels the context used by its background reconnect loop.

Impact

This removes duplicate reconnect attempts and the associated socket/connect races without changing login, QR pairing, or connected-state behavior.

Validation

  • go test -race ./whatsapp
  • go test -race ./...
  • go vet ./...

Verified against the repository's pinned whatsmeow version, where NewClient initializes EnableAutoReconnect: true.

@pingrishabh
pingrishabh marked this pull request as ready for review August 4, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant