Repository navigation
fix(zalouser): recover when listener handshakes stall - #109506
Conversation
The warnedEncryptedRooms and warnedCryptoMissingRooms Sets had no capacity limit. Each distinct roomId that produced an encrypted event would be added permanently, allowing unbounded growth over the gateway lifetime. - Cap warnedEncryptedRooms at 256 entries. - Cap warnedCryptoMissingRooms at 256 entries. - Skip add when the cap is reached so the dedupe Sets never grow without bound. Co-Authored-By: Claude <[email protected]> Signed-off-by: 廖石荣 0668000909 <[email protected]>
The zca-js listener WebSocket had no connect deadline, so an unreachable Zalo server would leave the listener silently stuck without firing connected, error, or closed events. - Add LISTENER_HANDSHAKE_TIMEOUT_MS (30s). - Listen for the connected event to clear the handshake timer. - Fail the listener with a descriptive error on timeout so the reconnect loop retries. - Clean up the timer and connected listener on stop/abort. Co-Authored-By: Claude <[email protected]> Signed-off-by: 廖石荣 0668000909 <[email protected]>
|
Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 10:16 PM ET / September 17, 2026, 02:16 UTC (Revision 5). ClawSweeper reviewWhat this changesThe PR adds a 30-second connection deadline and safe listener cleanup to Zalo Personal, with lifecycle regression coverage and supporting test and wrapper inventory corrections. Merge readiness✅ Ready for maintainer review This remains a useful, bounded repair: current main and v2026.9.4 lack the handshake deadline. Earlier findings are resolved, the recorded real-transport recovery proof is sufficient, and no blocking defect was found. Priority: P1 Review scores
Verification
How this fits togetherZalo Personal receives account messages through the zca-js WebSocket client and passes them into OpenClaw’s channel monitor and durable ingress queue. Listener failures settle the monitor so the Gateway’s existing restart supervisor can retry. flowchart TD
A[Saved Zalo session] --> B[Zalo Personal listener]
B --> C{WebSocket connects within deadline?}
C -->|Yes| D[Receive messages into durable ingress]
C -->|No| E[Stop socket and retire cached client]
E --> F[Monitor reports failure]
F --> G[Gateway restart supervisor]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -18, Tests +255, Other +3. Total +240 across 6 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep connection recovery in the Zalo listener owner and reuse the monitor’s existing settlement and Gateway restart paths. Do we have a high-confidence way to reproduce the issue? Yes, from source: accepting TCP while withholding the WebSocket upgrade leaves main’s listener without a connection deadline. The submitted fixture exercises that trigger; this read-only review did not execute it. Is this the best way to solve the issue? Yes. The patch repairs the existing listener lifecycle, matches the pinned dependency’s events, and avoids adding a competing retry mechanism or configuration surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ead7324bdb36. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Integrate current main while preserving the contributor branch. Initialize listener ownership and deadlines before startup, retire stopped API instances, and drain late socket errors through closure. Remove unrelated Matrix changes and cover real zca-js timeout, monitor settlement, and same-profile retry.
Use the existing deferred helper and exact fixture API surface, match the runtime logger contract, and bound loopback websocket frames. Preserve the verified real timeout and same-profile retry proof.
Preserve contributor ancestry while integrating the observed bounded-read regression repair. Reuse the canonical wrapper inventory, cold-checkout fixture and Slack receiver corrections from f91e0e0. Apply syntax-only lint corrections to the tested Zalo fixture without changing assertions or transport behavior.
Apply the reviewed type-only extraction from canonical PR150026 commit729eb63a68c71bee56544fb251dbe7d6ab42a56b to resolve the current-main import cycle exposed by PR109506 CI.
Resolve the equivalent type-only import paths in favor of the canonical ingress.types.ts owner landed by PR111148. Zalo production and real transport fixture are unchanged; the final six-file candidate passes fresh P0-P2 review and extension types/import-cycle checks.
|
Merged via squash.
|
* fix(matrix): bound warned room dedupe caches against unbounded growth The warnedEncryptedRooms and warnedCryptoMissingRooms Sets had no capacity limit. Each distinct roomId that produced an encrypted event would be added permanently, allowing unbounded growth over the gateway lifetime. - Cap warnedEncryptedRooms at 256 entries. - Cap warnedCryptoMissingRooms at 256 entries. - Skip add when the cap is reached so the dedupe Sets never grow without bound. Co-Authored-By: Claude <[email protected]> Signed-off-by: 廖石荣 0668000909 <[email protected]> * fix(zalouser): bound Zalo listener WebSocket handshake with timeout The zca-js listener WebSocket had no connect deadline, so an unreachable Zalo server would leave the listener silently stuck without firing connected, error, or closed events. - Add LISTENER_HANDSHAKE_TIMEOUT_MS (30s). - Listen for the connected event to clear the handshake timer. - Fail the listener with a descriptive error on timeout so the reconnect loop retries. - Clean up the timer and connected listener on stop/abort. Co-Authored-By: Claude <[email protected]> Signed-off-by: 廖石荣 0668000909 <[email protected]> * test(zalouser): type and bound the transport fixture Use the existing deferred helper and exact fixture API surface, match the runtime logger contract, and bound loopback websocket frames. Preserve the verified real timeout and same-profile retry proof. * fix(slack): reuse canonical ingress lifecycle leaf contract Apply the reviewed type-only extraction from canonical PR150026 commit729eb63a68c71bee56544fb251dbe7d6ab42a56b to resolve the current-main import cycle exposed by PR109506 CI. --------- Signed-off-by: 廖石荣 0668000909 <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Jason (Json) <[email protected]>
Record the approved 362706-byte startup baseline under a 355 KiB cap, preserving the 512-byte growth and 64-byte variance allowances. Exact base and merge builds emitted byte-identical UI assets; hosted CI measured the same size. Include the newly imported bundled plugin source utility in cold worktree fixtures, matching the repair already landed in #109506. Preserve all assertions and timeouts.
* feat(gateway): measure synchronous session-list CPU * fix(ci): repair native wrapper and skill-read checks Restore three newly imported modules in the shared native PR wrapper inventory. Observe fs-safe Root.read through its current final-fence hook while preserving all aggregate byte, status, and inventory assertions. Both defects reproduced before repair. All 24 plugin-skill bundle cases pass; nine focused native-wrapper cases pass on Blacksmith Testbox with unchanged limits. Independent review through P2 is clean. * fix(ci): refresh measured UI budget and cold worktree fixture Record the approved 362706-byte startup baseline under a 355 KiB cap, preserving the 512-byte growth and 64-byte variance allowances. Exact base and merge builds emitted byte-identical UI assets; hosted CI measured the same size. Include the newly imported bundled plugin source utility in cold worktree fixtures, matching the repair already landed in #109506. Preserve all assertions and timeouts. * test(slack): align Socket Mode fixtures with SDK acknowledgements Give the shared receiver mock real EventEmitter listener ownership and an asynchronous acknowledgement sender, preserving the production envelope guard. Narrow WebSocket ArrayBuffer data before converting it so the loopback test typechecks without copying an existing Buffer. The former ingress-cleanup failure reproduces before this repair; all 120 selected Slack tests and the extension test-type graph pass afterward.
* feat(gateway): measure synchronous session-list CPU * fix(ci): repair native wrapper and skill-read checks Restore three newly imported modules in the shared native PR wrapper inventory. Observe fs-safe Root.read through its current final-fence hook while preserving all aggregate byte, status, and inventory assertions. Both defects reproduced before repair. All 24 plugin-skill bundle cases pass; nine focused native-wrapper cases pass on Blacksmith Testbox with unchanged limits. Independent review through P2 is clean. * fix(ci): refresh measured UI budget and cold worktree fixture Record the approved 362706-byte startup baseline under a 355 KiB cap, preserving the 512-byte growth and 64-byte variance allowances. Exact base and merge builds emitted byte-identical UI assets; hosted CI measured the same size. Include the newly imported bundled plugin source utility in cold worktree fixtures, matching the repair already landed in openclaw#109506. Preserve all assertions and timeouts. * test(slack): align Socket Mode fixtures with SDK acknowledgements Give the shared receiver mock real EventEmitter listener ownership and an asynchronous acknowledgement sender, preserving the production envelope guard. Narrow WebSocket ArrayBuffer data before converting it so the loopback test typechecks without copying an existing Buffer. The former ingress-cleanup failure reproduces before this repair; all 120 selected Slack tests and the extension test-type graph pass afterward.
What Problem This Solves
Fixes: Zalo user-account monitoring can remain silently stuck when a WebSocket handshake never finishes.
User Impact
A stalled handshake now reports a timeout after 30 seconds and releases listener ownership so the channel can retry. Successful connections cancel the deadline; stop and abort clean up without a late unhandled socket error. No configuration or migration is required.
Why This Change Was Made
Listener ownership, handlers, and timers must exist before startup can emit an event or throw. Cleanup retires the stopped API so a retry cannot reuse a listener whose old socket is still closing.
This builds on @lsr911's original timeout fix and preserves the contributor branch ancestry. Unrelated Matrix changes were removed.
Also reuses the existing canonical native-wrapper/source-preparation input inventory fixes needed by CI. Current-main integration includes the landed bounded-read hook and Slack callback/import-cycle repairs; this PR has no remaining Slack or Matrix delta.
Evidence
[email protected]andwstransport proof passed with a real 30-second deadline: stalled loopback WebSocket upgrade → timeout → real monitor rejection and durable-ingress drain → same-profile monitor restart using a fresh listener → successful WebSocket connection → clean abort settlement.The transport proof stubs only account restoration. It does not claim authenticated Zalo login or a full live-Gateway automatic retry run.
Real transport trace