Repository navigation
fix(macos): back off failed Gateway connects - #116114
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 7:17 PM ET / 23:17 UTC. ClawSweeper reviewWhat this changesThe PR adds bounded exponential backoff to the shared macOS Gateway connection path so concurrent callers coalesce behind one delayed retry instead of repeatedly creating failed WebSocket connections. Merge readinessKeep this PR open for explicit macOS-owner merge judgment. The patch has no concrete correctness or security finding from the reviewed change, but it deliberately changes the shared Gateway reconnect schedule after failure; the protected Priority: P1 Review scores
Verification
How this fits togetherThe macOS app uses a shared Gateway channel to connect native surfaces to the local or remote Gateway. Connection attempts authenticate, establish a WebSocket, and then serve requests; this change inserts retry scheduling before a replacement socket is created after failure. flowchart LR
A[macOS app surfaces] --> B[Shared Gateway channel]
B --> C[Connect attempt]
C --> D{Connected?}
D -->|Yes| E[Serve Gateway requests]
D -->|No| F[Shared failure cooldown]
F --> C
C --> G[Cancellation or shutdown]
G --> B
Decision needed
Why: This is a product and lifecycle tradeoff rather than a mechanical defect: the patch prevents connection bursts by intentionally delaying recovery after failure, and tests cannot determine the acceptable user-visible recovery schedule. Before merge
Agent review detailsSecurityNone. PR surfaceOther +157. Total +157 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one shared, cancellation-safe reconnect cooldown and merge only after the macOS owner confirms the bounded delay and device-token fast-retry behavior are the intended native-app lifecycle contract. Do we have a high-confidence way to reproduce the issue? No high-confidence current-main reproduction was independently established in this review. The submitted live observation and the changed shared connection path make the reported retry burst source-reproducible, but the persisted-identity failure was not rerun against the reviewed head. Is this the best way to solve the issue? Unclear pending owner confirmation. A single shared, monotonic cooldown is the narrow maintainable place to stop competing retries, but only the macOS owner can confirm that its recovery timing is the best supported lifecycle contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9e041cd3867f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
* fix(macos): back off failed gateway connects * fix(macos): skip backoff for transport cancellation
What Problem This Solves
Fixes an issue where macOS app surfaces could repeatedly retry a failed Gateway connection, creating rapid WebSocket connection bursts and repeating endpoint/process work when the shared connection could not load its persisted device identity.
Why This Change Was Made
Failed initial connections now arm a monotonic exponential cooldown on the shared
GatewayChannelActorbefore another socket is created. Concurrent callers coalesce behind that one delayed attempt, successful connections reset the cooldown, device-token recovery remains fast, and cancellation or shutdown cannot create a stale socket after the delay.User Impact
When Gateway authentication or local device identity access is temporarily unavailable, the native app avoids a hot reconnect loop and stays substantially quieter in CPU and system work while still retrying automatically.
Evidence
swift test --package-path apps/macos --filter GatewayChannelConnect: 13 passed.swift test --package-path apps/macos --filter 'GatewayChannel(Disconnect|Request|DeviceTokenRetry|Shutdown)': 20 passed.swift test --package-path apps/macos --filter 'transport cancellation does not publish readiness failure': passed 5 consecutive runs after excluding URL-loading cancellation from the cooldown.git diff --check: clean.