Repository navigation
Description
Overview
While building the not-ready → degraded → recovered integration test for #1525, a real readiness gap was found in packages/dev-tools/src/dev-proxy.ts's gRPC client — not in application code, but worth documenting and fixing since it undermines confidence in the e2e harness that ADR-048 designates as the canonical integration-test vehicle.
Problem Statement
dev-proxy.ts constructs its gRPC-js client once, at proxy process startup, against the daemon's socket address (resolveSocketAddress() at module load). If the proxy starts before the daemon has bound that socket — which DaemonTestHarness.startDeferred() does deliberately, to create a not-ready window for readiness tests — the gRPC-js channel enters its own internal reconnect/backoff cycle (observed: WatchNodes stream error, reconnecting in 2s: 14 UNAVAILABLE ... connect ENOENT <socket>).
This backoff is independent of the daemon's actual socket becoming reachable moments later. A raw socket-reachability probe (net.createConnection against the socket path) can report the daemon as up while the proxy's own gRPC-js channel is still mid-backoff and will fail the very next RPC — silently, since callers like schemas.ts's loadSchemas() catch and log rather than throw.
Confirmed directly via debug instrumentation during a real run: the daemon's socket read as reachable, daemon-status.ts correctly fired its reconnect callback at that moment, but the resulting getAllSchemas() HTTP call still failed because the proxy's channel hadn't finished reconnecting.
Investigation Notes
- This is NOT a production bug. The desktop app's Rust/tonic
GrpcClient(packages/desktop-app/src-tauri/src/services/grpc_client.rs,connect_with_connector_lazy) has no equivalent cached-backoff state — verified with a scratch Rust integration test: a call issued immediately after the daemon binds its socket succeeds on the very next attempt, with no carried-forward failure. Tonic's lazy channel retries the connector fresh per call; gRPC-js's channel owns its own timer-driven state machine that the caller does not control. - The workaround landed in Establish one daemon-readiness contract to stop per-call-site startup races #1525's e2e test (
daemon-harness.ts's newwaitUntilProxyReady()) is to poll a real data-plane round-trip instead of the socket — this correctly unblocks that one test, but the underlying dev-proxy behavior is still there for any other test or workflow that starts the proxy ahead of the daemon.
Proposed Solution
Options to evaluate:
- Have
dev-proxy.tsretry/reconstruct its gRPC-js client (or force a channel reset) when it detects the daemon's socket has just become reachable after being down. - Expose a
/health-style endpoint on dev-proxy that reports actual gRPC channel state (not just "the HTTP server is up"), so callers have a real signal instead of needing to probe with a real RPC. - Investigate gRPC-js channel options (e.g., explicit connectivity state watching / forcing
tryToConnect) to shorten or bypass the backoff once the underlying transport is known to be available again.
Acceptance Criteria
- Root cause and fix (or accepted mitigation) decided and documented
- A regression test proves a dev-proxy started before the daemon recovers promptly once the daemon becomes reachable, without needing callers to poll a real RPC as a workaround
-
DaemonTestHarness.waitUntilProxyReady()can be simplified or removed if the underlying proxy behavior is fixed at the source
Technical Specifications
Reference Files
packages/dev-tools/src/dev-proxy.ts— constructs the gRPC-js client, resolves socket address at module loadpackages/desktop-app/src/tests/e2e/daemon-harness.ts—DaemonTestHarness.startDeferred()and thewaitUntilProxyReady()workaroundpackages/desktop-app/src-tauri/src/services/grpc_client.rs— the production tonic path confirmed NOT to have this gap
Related Issues
- Establish one daemon-readiness contract to stop per-call-site startup races #1525 (readiness contract + integration test that surfaced this)
Activity
mstomar125 commentedon Jul 29, 2026
Picking this up now.
mstomar125 commentedon Jul 29, 2026
Resolved in PR #1803 (merged). Root cause confirmed by reading grpc-js 1.14.4: the reconnect backoff lives on the subchannel and grows 1s→120s independent of the socket returning; pick-first's resetBackoff is a no-op and startConnecting doesn't restart the timer, so bounding the backoff via channel options (initial=max=100ms) plus gating RPCs on waitForReady is the fix. Recovery measured at ~127ms vs ~2234ms unpatched. waitUntilProxyReady() simplified to socket reachability. Production tonic path untouched; grpc-js added dev-only.