[codex] Cancel Android gateway pending RPCs on close#98067
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 2, 2026, 9:12 AM ET / 13:12 UTC. Summary PR surface: Other +152. Total +152 across 4 files. Reproducibility: yes. source-reproducible: current main stores waiters in a session-wide map and closeQuietly closes sockets without draining pending RPCs, so a slow RPC can wait for timeout after disconnect. This read-only review did not run local tests, but the PR adds focused regression coverage for the failing path. 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:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the per-connection pending-RPC cleanup after required checks finish, keeping the disconnect-cancellation and replacement-connection regression tests. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main stores waiters in a session-wide map and closeQuietly closes sockets without draining pending RPCs, so a slow RPC can wait for timeout after disconnect. This read-only review did not run local tests, but the PR adds focused regression coverage for the failing path. Is this the best way to solve the issue? Yes. Per-Connection waiter ownership with synchronized registration and drain fixes the lifecycle boundary; a session-wide close drain would risk canceling replacement-connection waiters, which the new reconnect test guards. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b60e8c48382d. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Other +152. Total +152 across 4 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
|
b405058 to
8c6f818
Compare
addd263 to
4f20fd8
Compare
4f20fd8 to
726982e
Compare
|
Merged via squash.
|
* fix: cancel Android gateway pending RPCs on close * fix(android): isolate pending RPCs per connection * style(android): separate RPC waiter invariant * chore(android): align native i18n inventory --------- Co-authored-by: NianJiuZst <180004567+users.noreply.github.com> Co-authored-by: Peter Steinberger <[email protected]>
* fix: cancel Android gateway pending RPCs on close * fix(android): isolate pending RPCs per connection * style(android): separate RPC waiter invariant * chore(android): align native i18n inventory --------- Co-authored-by: NianJiuZst <180004567+users.noreply.github.com> Co-authored-by: Peter Steinberger <[email protected]>


What Problem This Solves
Android
GatewaySessionkept pending RPC waiters in a session-wide map, but an intentional disconnect/reconnect path closed the socket without cancelling pending requests. Those callers could wait until their request timeout even though the owning WebSocket had already been closed.Why This Change Was Made
This gives each
Connectionits own pending request id set. RPC registration, response, timeout, cancellation, send failure, and close now remove ids consistently, andcloseQuietly()cancels only the pending ids owned by that connection. The extra closed-connection check covers the race where a request registers against a connection that has just started closing.User Impact
Android callers no longer sit on stale Gateway RPCs after an intentional disconnect or reconnect. Newer connections are not affected by cleanup from an older socket.
Evidence
cd apps/android && ./gradlew :app:testThirdPartyDebugUnitTest --tests ai.openclaw.app.gateway.GatewaySessionInvokeTest --tests ai.openclaw.app.gateway.GatewaySessionReconnectTest --tests ai.openclaw.app.gateway.GatewaySessionInvokeTimeoutTestcd apps/android && ./gradlew :app:ktlintCheckfails only on untouched upstream files:apps/android/app/src/main/java/ai/openclaw/app/GatewayExecApprovals.ktandapps/android/app/src/main/java/ai/openclaw/app/ui/design/ClawSurfaces.kt.git diff --check.agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main