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
+9 -9
View File
@@ -794,14 +794,14 @@
"type": "qr"
},
"folder": "whatsapp",
"version": 6,
"version_string": "2.0.6",
"version_release_date": "2026-07-21",
"version": 7,
"version_string": "2.1.0",
"version_release_date": "2026-08-23",
"files": [
{
"path": "connector.json",
"sha256": "6ccae6fdf863bb6bd531d9ee0c4dcc65d46c18dd5a5f01ec914be7788f05aa31",
"size": 1354
"sha256": "87bac98a524c604ca016a80b26200ae16aaee3926baecfe99e1c336833823307",
"size": 1485
},
{
"path": "icon_lg.png",
@@ -815,13 +815,13 @@
},
{
"path": "index.js",
"sha256": "0bfaa3c5449f22a4e2c4c99c6e9402bb24651647eca9a36dbd7a639c95a6bfd6",
"size": 21846
"sha256": "fa1f1c31c1f3b6b32df3de0a1175e1cb51a0417dce7e3aa52fa8655900dd2967",
"size": 29495
},
{
"path": "package.json",
"sha256": "b99a9dccfd286b59e8482076129f2e40f7b339eba6c3db2a744887d65bd4964e",
"size": 302
"sha256": "d4c6c01230729388f418b3a2b05d5a0dedeb4af78ebde83f0669117dd71db721",
"size": 325
}
]
},