Repository navigation
fix(gateway-client): bound websocket opening handshake waits - #108348
Conversation
e98f8ab to
2ce8811
Compare
|
Codex review: needs maintainer review before merge. Reviewed July 15, 2026, 11:35 PM ET / July 16, 2026, 03:35 UTC. Summary PR surface: Source +11, Tests +105. Total +116 across 2 files. Reproducibility: yes. The production GatewayClient can be pointed at a real loopback TCP peer that accepts the socket but never returns a WebSocket upgrade; current main remains pre-open, while the patched client reports the upstream opening-handshake timeout near the configured deadline. Review metrics: 2 noteworthy metrics.
Stored data model 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
Maintainer decision needed
Security Review detailsBest possible solution: Use one canonical preauth budget for both the WebSocket opening upgrade and post-open challenge phase, with coverage for timeout failure, a delayed successful upgrade under a raised configured budget, and observable reconnect/error propagation. Do we have a high-confidence way to reproduce the issue? Yes. The production GatewayClient can be pointed at a real loopback TCP peer that accepts the socket but never returns a WebSocket upgrade; current main remains pre-open, while the patched client reports the upstream opening-handshake timeout near the configured deadline. Is this the best way to solve the issue? Yes, with one upgrade-safety proof gap. Reusing the existing preauth budget is narrower and more maintainable than adding another timeout surface, but a delayed-success test or live remote proof should confirm that raising the existing setting preserves slow valid connections. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 957cc81175a3. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +11, Tests +105. Total +116 across 2 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
|
96ada91 to
26ec937
Compare
26ec937 to
1891e87
Compare
|
Merged via squash.
|
…w#108348) * fix(gateway-client): bound websocket opening handshake waits * test(gateway-client): harden handshake timeout proof --------- Co-authored-by: Peter Steinberger <[email protected]>
…w#108348) * fix(gateway-client): bound websocket opening handshake waits * test(gateway-client): harden handshake timeout proof --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
GatewayClient.createSocketconfiguredmaxPayload(and optional TLS) but never setwshandshakeTimeout. The connect-challenge watchdog inprotocol-clientonly arms after the socketopenevent, so a peer that accepts TCP without completing the WebSocket upgrade could leave CLI/TUI/node Gateway connects hanging until the OS TCP stack gave up.Why This Change Was Made
resolvePreauthHandshakeTimeoutMspath (gateway.handshakeTimeoutMs/preauthHandshakeTimeoutMs, default 15s).handshakeTimeouton the productionWebSocketconstructor options.No new config/env surface.
User Impact
Before: A Gateway endpoint that accepted TCP without finishing the WebSocket handshake could pin
GatewayClient.start()forever; challenge timeout never started.After: Opening-handshake waits fail closed after the configured preauth handshake budget (
Opening handshake has timed out), so reconnect/error handling can proceed.Evidence
packages/gateway-client/src/client.tsGatewayClient.createSocket→GatewayProtocolClientstart/reconnect (CLI/TUI/src/gateway/call.tsbootstrap)handshakeTimeout: 30_000(Discord/Slack/Signal); this package reuses the existing preauth handshake budget instead of adding a parallel knobpackages/gateway-client/src/client.handshake.test.tspackages/gateway-client/src/client.watchdog.test.tsCaller-path Vitest
Adjacent regression
Real behavior proof
Commands run:
Before fix:
Production
createSocketWebSocket options had nohandshakeTimeout. Against a TCP peer that accepts but never upgrades,GatewayClient.start()never reachedopen, so the challenge watchdog never armed and the connect attempt could hang indefinitely.After fix:
createSocketsetshandshakeTimeoutfromresolvePreauthHandshakeTimeoutMs. Against a real loopback TCP peer that accepts but never upgrades, withpreauthHandshakeTimeoutMs: 250:Default unresolved budget remains
DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS(15_000), matching existing gateway preauth config.Evidence after fix:
What was not tested:
Live remote Gateway hosts / Tailscale Serve paths; packaging beyond the production
wsclient options used byGatewayClient.createSocket.AI Assistance
AI-assisted (Cursor). Author reviewed the production ownership, timeout contract, tests, and proof output.