Skip to content

fix(baileys): enable initial sync + dialect-agnostic chatId filter + debug logging#375

Merged
rmyndharis merged 1 commit into
rmyndharis:mainfrom
tobiasstrebitzer:feat/baileys-sync-hardening
Jun 20, 2026
Merged

fix(baileys): enable initial sync + dialect-agnostic chatId filter + debug logging#375
rmyndharis merged 1 commit into
rmyndharis:mainfrom
tobiasstrebitzer:feat/baileys-sync-hardening

Conversation

@tobiasstrebitzer

@tobiasstrebitzer tobiasstrebitzer commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Depends on #349 - stacks on feat/typed-waid-349; that PR's commit appears in this diff until #349 merges. Review/merge #349 first.

Three independent Baileys-engine fixes that surfaced while testing #349 on a real session.

Initial sync was silently disabled

Baileys defaults shouldSyncHistoryMessage to () => !!syncFullHistory, so with syncFullHistory unset the entire initial sync (address-book / app-state) never ran - no contacts, chat list, recent messages, or lid -> phone mappings ever arrived (Socket/index.js + Socket/chats.js go straight to Online). The adapter now passes shouldSyncHistoryMessage: () => true, enabling the sync while keeping the full-archive download opt-in via BAILEYS_SYNC_FULL_HISTORY (WhatsApp then sends the recent window + contact/app-state snapshot, not the entire message history).

Verified against @whiskeysockets/baileys@6.7.23 source and corroborated by upstream issues (e.g. WhiskeySockets/Baileys#2077, NousResearch/hermes-agent#11951).

Dialect-agnostic chatId filter on message history

A chat addressed as <phone>@c.us (the neutral list id) now also returns messages stored under <phone>@s.whatsapp.net (e.g. an outbound send addressed by a raw engine id), so the conversation view is no longer empty when the stored and queried dialects differ. Reuses the #349 from-filter resolution.

BAILEYS_LOG_LEVEL + receipt instrumentation

BAILEYS_LOG_LEVEL (trace|debug|info|warn|error, silent by default) surfaces the Baileys library's own diagnostics; trace dumps the decoded WhatsApp wire frames to stdout (context baileys-wire). Plus contacts/chats/history-set receipt logging, for diagnosing sync issues.

…debug logging

Downstream Baileys-engine hardening, stacked on the typed-WaId work (rmyndharis#349).

- Initial sync: pass shouldSyncHistoryMessage: () => true. Baileys defaults it to
  () => !!syncFullHistory, so with syncFullHistory unset it silently disabled the entire
  initial sync - no contacts, chat list, recent messages, or lid->phone mappings ever
  arrived. The full-archive download stays opt-in via BAILEYS_SYNC_FULL_HISTORY.
- Message history chatId filter resolves across dialects (reuses the from-filter's
  resolveJidCandidates), so a chat keyed @c.us also matches messages stored under
  @s.whatsapp.net - fixes the empty conversation view after contact/chat canonicalization.
- BAILEYS_LOG_LEVEL surfaces the Baileys library's own logs (trace dumps the decoded WA
  wire frames), plus contacts/chats/history-set receipt instrumentation, for diagnosing
  sync issues. Silent by default.
@rmyndharis rmyndharis force-pushed the feat/baileys-sync-hardening branch from 50ccff7 to b5961fa Compare June 20, 2026 09:37
@rmyndharis

Copy link
Copy Markdown
Owner

Rebased onto main now that #374 has landed, so this is down to its own three-fix delta. I reviewed each against the source and they hold up nicely:

  • shouldSyncHistoryMessage: () => true — confirmed against @whiskeysockets/baileys@6.7.23 that the default (() => !!syncFullHistory) was silently skipping the entire initial sync; the full-archive download stays opt-in via BAILEYS_SYNC_FULL_HISTORY. Good catch, and an important one.
  • Dialect-agnostic chatId filter cleanly reuses the candidate-expansion helper from feat(engine): typed WaId + persistent lid->phone resolution table + message from-filter #374.
  • BAILEYS_LOG_LEVEL is silent by default; just flagging for anyone reading later that trace will surface decoded wire frames (incl. message content) by design — opt-in only.

Approving and merging. Thanks for chasing these down on a real session.

@rmyndharis rmyndharis merged commit 3d8483a into rmyndharis:main Jun 20, 2026
5 checks passed
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.

2 participants