Addresses 2 review comments on PR #384:
- Codex P2: the fresh-pair test ended the socket immediately after the
buffer assertion, leaving the 2s setTimeout in chats.ts:1522 alive.
Its callback fired post-teardown and emitted "Cannot log after tests
are done" via baileys-logger, making the suite noisy and trippable
by --detectOpenHandles. Drain the timer with a 2.1s wait before
cleanup; bump the per-test timeout to 10s to accommodate it.
- Copilot: the file header said "live messages are not held for up to
4 seconds", but the chats.ts AwaitingInitialSync timeout is 2s.
Replace the stale literal with "the initial-sync window" so the
comment doesn't drift again when the timeout is tuned.
Skipped intentionally (per PR review):
- CodeRabbit Major (try/finally cleanup): diverges from the pattern
used by the only sibling test (connection-deadlock.test.ts).
- CodeRabbit Nitpick (replace 50ms sleeps with deterministic waits):
not flaky in practice; sibling test uses the same pattern.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Ports the upstream reconnection-sync-skip test from Baileys PR #2350
and adapts it to cover InfiniteAPI's dual-signal reconnect detection
in chats.ts:
1. accountSyncCounter > 0 (a previous full sync completed)
2. socketSkippedOfflineBuffer (forwarded from socket.ts when
hadStaleRoutingInfo is true, e.g. routingInfo discarded on start)
Both are required because they cover different reconnect scenarios
and the absence of the second branch causes a buffer mismatch where
socket.ts skips the offline buffer while chats.ts still waits in
AwaitingInitialSync — stalling live messages for up to 4 seconds.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>