whatsapp: fix history sync + session corruption, Baileys 7.0.0-rc14 (v7 / 2.1.0)

Diagnosed from the live server (two users, two accounts, one shared log).

- history sync was gated off entirely on Baileys 6.7.x: the library derives
  shouldSyncHistoryMessage from syncFullHistory when unset, and the connector
  shipped syncFullHistory: false. Now both are passed explicitly, so behaviour
  no longer depends on the resolved Baileys version. browser -> ['Mac OS', ...]
  because PLATFORM_MAP only grants a desktop-grade sync to Mac OS / Windows.
- reconnects leaked their socket, leaving two writers over auth/: no end(), no
  removeAllListeners(). ~15 reconnects/day produced 1422 Bad MAC lines, all on
  the account's own LID device 0. Added teardownSock(), per-socket generation
  guards, and a single-slot reconnect timer with exponential backoff.
- undecryptable messages (stubType CIPHERTEXT) were stored with empty text and
  rendered as blank transcript lines; now labelled and counted. Text-less
  protocol frames are dropped.
- fetchLatestBaileysVersion() ran on every reconnect; now cached for 6h.
- libsignal's direct console.error spam collapsed into one counted line, log
  lines tagged with the linked account, console.log redirected off stdout.

Baileys pinned ^6.7.9 -> 7.0.0-rc14 (the range resolved to 6.7.24 for one user
and 6.17.16 for the other). RC is ESM-only, so index.js is now ESM.

Verified on skald-runtime:v4 (Node 20.19.2): initialize, tools/list, status,
list_chats, version fetch, QR, and logout -> teardown -> single reconnect.

Remaining gap: the store is still in-memory only, so synced history is lost on
the next process restart.
This commit is contained in:
Daniele
2026-08-23 18:15:56 +01:00
parent 040a0b2320
commit a2bbedad40
6 changed files with 270 additions and 87 deletions
+10 -9
View File
@@ -16,19 +16,20 @@
"qr"
],
"dependencies": [
"@whiskeysockets/baileys>=6.7.9",
"qrcode>=1.5.4"
"@whiskeysockets/baileys@7.0.0-rc14",
"qrcode@1.5.4"
],
"setup_instructions": [
"Skald installs dependencies automatically (npm install).",
"Open the connector in Skald and scan the QR code with your WhatsApp phone.",
"The session is persisted and survives restarts."
"The session is persisted and survives restarts.",
"The phone lists this device as \"Mac OS Chrome\": that browser identity is what makes WhatsApp deliver the full history sync."
],
"docs": [
{
"lang": "en",
"description": "Send and read WhatsApp messages from your own linked account. Uses Baileys multi-device protocol \u2014 no browser, no Chromium needed. Link via QR code.",
"llm_short_description": "WhatsApp \u2014 read and send messages, manage chats, search contacts and messages, and download media from the user's linked WhatsApp session. QR-based authentication."
"description": "Send and read WhatsApp messages from your own linked account. Uses Baileys multi-device protocol no browser, no Chromium needed. Link via QR code.",
"llm_short_description": "WhatsApp read and send messages, manage chats, search contacts and messages, and download media from the user's linked WhatsApp session. QR-based authentication."
}
],
"auth": {
@@ -44,7 +45,7 @@
"homepage": "https://github.com/WhiskeySockets/Baileys",
"icon_small": "icon_sm.png",
"icon_large": "icon_lg.png",
"version": 3,
"version_string": "2.0.3",
"version_release_date": "2026-07-21"
}
"version": 7,
"version_string": "2.1.0",
"version_release_date": "2026-08-23"
}