fix: tctoken 463/479 — peer guard + retry logic

* feat: apply PR #2339 missing commits (ced3305 + fe5a37c)

Apply two Feb-19 commits from WhiskeySockets/Baileys PR #2339 that
were missing from the initial integration:

ced3305 — Prevent tctoken attachment to peer (AppStateSync) messages
- Add isPeerMessage guard: additionalAttributes?.['category'] === 'peer'
- Exclude peer messages from is1on1Send to fix error 479 (SmaxInvalid)
  which was causing hundreds of rejections on multi-device sync JIDs

fe5a37c — Error 463 retry logic + blocking→non-blocking refactor
- Replace blocking await getPrivacyTokens() with fire-and-forget .then/.catch
  so the send path is never delayed by a token fetch
- Add tcTokenRetriedMsgIds Set in messages-recv.ts to track retried msgIds
- On error 463 (MissingTcToken): wait 1.5s then relay the message once,
  allowing the server's tctoken notification to arrive before resend
- Add retry_463_ok log event to baileys-logger for observability
This commit is contained in:
Renato Alcara
2026-02-20 00:39:21 -03:00
committed by GitHub
parent 37e9a1ef39
commit 33cce2a6c2
3 changed files with 84 additions and 65 deletions
+4 -1
View File
@@ -958,7 +958,7 @@ export function logLidMapping(
* // Output: [BAILEYS] 🔑 TcToken expired → 5511999999999@s.whatsapp.net { age: 32d }
*/
export function logTcToken(
event: 'stored' | 'expired' | 'fetch' | 'fetched' | 'reissue' | 'reissue_ok' | 'reissue_fail' | 'prune' | 'error_463' | 'error_479' | 'attached',
event: 'stored' | 'expired' | 'fetch' | 'fetched' | 'reissue' | 'reissue_ok' | 'reissue_fail' | 'prune' | 'error_463' | 'error_479' | 'attached' | 'retry_463_ok',
data?: Record<string, unknown>,
sessionName?: string
): void {
@@ -1004,6 +1004,9 @@ export function logTcToken(
case 'error_479':
console.log(`${prefix} ⚠️ TcToken smax-invalid (479)${jid}${extraStr}`)
break
case 'retry_463_ok':
console.log(`${prefix} 🔄 TcToken retry 463 OK${jid}${extraStr}`)
break
}
}