Repository navigation
fix(zalo): journal polled inbound updates across restarts - #110559
wangmiao0668000666 wants to merge 1 commit into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 18, 2026, 4:11 AM ET / 08:11 UTC. Summary PR surface: Source +151, Tests +195. Total +346 across 9 files. Reproducibility: unclear. for a live reproduction. The PR describes a source-level crash/dispatch-loss path, but the current-main Zalo implementation could not be inspected in this environment. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Compare the Zalo adapter with the current shared ingress-drain contract and a merged channel reference, then obtain a redacted real Zalo polling or webhook restart/retry transcript before merge. Do we have a high-confidence way to reproduce the issue? Unclear for a live reproduction. The PR describes a source-level crash/dispatch-loss path, but the current-main Zalo implementation could not be inspected in this environment. Is this the best way to solve the issue? Unclear. Using the shared durable ingress drain is consistent with the supplied adjacent-channel context, but the Zalo-specific lifecycle and transport assumptions still need direct contract review. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 34440523cd03. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +151, Tests +195. Total +346 across 9 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Closing: the webhook half of this PR is superseded by steipete's #110630 ( The polling half remains a live gap on Branch stays on the fork for reference. Thanks for the reviews! |
What Problem This Solves
Zalo long-polling — the default inbound mode when no webhook is configured — loses messages permanently in two windows:
getUpdates(extensions/zalo/src/api.ts:249-258) sends only{timeout}; no offset parameter exists andZaloUpdate(api.ts:51-58) carries no update id, so the client can never confirm or replay — the server consumes each update on response. In the poll loop (monitor.ts), a crash between thegetUpdatesresponse andprocessUpdatecompletion destroys the only copy of the message. It is never redelivered.await processUpdate(...)directly and the surroundingcatchonly loggedZalo polling errorand polled on — any handler failure silently dropped the consumed update.The webhook sibling had the weaker form of the same bug: detached processing with an immediate 200 and a memory-only replay guard (5 min TTL), so a restart forgot recent deliveries and a post-ack handler failure was committed-and-dropped.
Why This Change Was Made
This mirrors the maintainer-blessed "inbound durability across restart" wave that landed on
mainin the last 24h — #110418 whatsapp, #110409 imessage, #110386 mattermost, #110357 msteams, #110274 discord, #109910 slack, #109866 sms, #109907 signal, line webhook-spool (#109655/#109819) — all built on the core durable ingress drain (src/channels/message/ingress-drain.ts, #108656 lineage). Zalo adopts the same mechanism through the same SDK seam (openclaw/plugin-sdk/channel-outbound:createChannelIngressDrain,bindIngressLifecycleToReplyOptions), storing rows in the existingchannel_ingress_eventstable of the shared state DB — no schema change.Design (closest template:
extensions/sms/src/ingress-spool.ts, mapped to Zalo's polling chokepoint):extensions/zalo/src/monitor-ingress.ts:createZaloIngressSpooljournals each inbound update before it can be lost. Event id =JSON.stringify([chatId, senderId, messageId])(JSON encoding keeps ids unambiguous;message_idis contract-required perapi.ts:31), lane = one per chat for per-conversation serialization.drainOnce()+waitForIdle()each cycle (preserves the old one-at-a-time backpressure), pumping retries even on empty polls. Dispatch errors are now drain-owned: retry with backoff (8 attempts / 24h dead-letter gate) instead of silent drop.core.channel.inbound.dispatch(turnAdoptionLifecycle) so claims tombstone when recovery-relevant turn state is durable; events dropped pre-dispatch (unauthorized, sticker/unsupported, empty text) complete at dispatch return.Honest note: Zalo's server-side consume-on-response semantics are code-inferred — no offset/id field exists in the client contract, so the journal is correct under any server semantics (worst case it dedupes a redelivery).
User Impact
message(no-ops downstream) and malformed messages missing the contract-requiredmessage_idare acknowledged without journaling (logged), since they can be neither deduped nor replayed.Evidence
extensions/zalo/src/monitor-ingress.test.ts(8 tests, real SQLite queues in temp dirs viacreateChannelIngressQueueForTests): crash-window replay (journal → dispose without dispatch → fresh spool replays exactly once), tombstone dedupe, complete-at-dispatch-return, retryable-failure retry, permanent-failure dead-letter, ignore-without-message, per-chat event-id scoping, per-chat lane.monitor.webhook.test.ts(14 tests): real-spool journal-before-ack + detached drain over HTTP, durable replay dedupe, 500-on-append-failure redelivery contract, plus retained rate-limit/auth guards.enqueueremoved, 6/8 spool tests go red (crash replay, dedupe, complete-at-return, retry, scoping, lane); restored, all 8 pass.setup-surface.test.tswizard prompt, locale-dependent) fails identically on an untouchedmaincheckout — pre-existing, unrelated.node scripts/run-tsgo.mjs -p tsconfig.extensions.json: zero errors in touched files (only the 3 pre-existingpackages/net-policy/src/ip.tserrors from stale worktreeipaddr.jstypes).