Repository navigation
Fix dev-proxy gRPC-js reconnect backoff so it recovers when the daemon socket appears - #1803
Merged
Merged
Conversation
…n socket appears The Bun dev-proxy built its gRPC-js client once at startup. When the proxy started before the daemon bound its socket, the channel's subchannel entered an ever-growing reconnect backoff (grpc-js default 1s->120s) independent of the socket actually becoming reachable moments later, so the next RPC failed silently with UNAVAILABLE — a real gap in the ADR-048 e2e harness that a raw socket probe could not detect. - Extract the gRPC client setup into dev-tools/src/grpc-client.ts so the not-ready -> recovered behavior is regression-testable without the full proxy - Bound the reconnect backoff to a fixed ~100ms via channel options (grpc.initial_reconnect_backoff_ms / grpc.max_reconnect_backoff_ms) so the channel re-probes ~10x/second and recovers within ~100ms of the socket appearing, regardless of how long the daemon was down - Gate each RPC (and the WatchNodes bridge) on client.waitForReady(deadline) so a call issued right after the daemon binds waits for READY instead of failing instantly - Add dev-proxy-recovery.e2e.ts: one RPC issued before a late-binding stub server, asserted to resolve promptly with no real-RPC polling - Simplify DaemonTestHarness.waitUntilProxyReady() to socket reachability now that the proxy self-heals at the source The production Tauri/tonic path has no equivalent cached-backoff state and is untouched. grpc-js/proto-loader added as desktop-app devDependencies for the test only; community/production bundle unaffected. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Contributor
Author
|
APPROVE — Independent review + adversarial re-review both CONFIRMED. Empirically validated the fix (channel recovers ~127ms after socket bind vs ~2234ms unpatched; the regression test genuinely fails without the fix). Refactor is behavior-preserving (same proto paths/loader options), |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1551.
Problem
The Bun dev-proxy builds its gRPC-js client once at startup. When the proxy starts before the daemon binds its socket (which
DaemonTestHarness.startDeferred()does deliberately), the channel's subchannel enters an ever-growing reconnect backoff (grpc-js default 1s→120s) that is independent of the socket actually becoming reachable moments later — so the next RPC fails silently with UNAVAILABLE. A real gap in the ADR-048 e2e harness that a raw socket probe can't detect. The production Tauri/tonic path has no equivalent cached-backoff state and is untouched.Fix
packages/dev-tools/src/grpc-client.tsso the not-ready→recovered behavior is regression-testable in isolation.grpc.initial_reconnect_backoff_ms/grpc.max_reconnect_backoff_ms— the channel re-probes ~10×/second and recovers within ~100ms of the socket appearing (verified: ~127ms with the fix vs ~2234ms without).client.waitForReady(deadline)so a call issued right after the daemon binds waits for READY instead of failing instantly.dev-proxy-recovery.e2e.ts: one RPC issued before a late-binding stub server, asserted to resolve promptly with no real-RPC polling. It fails without the fix and passes with it.DaemonTestHarness.waitUntilProxyReady()to socket reachability now that the proxy self-heals at the source.Notes
resetBackoffis a no-op andstartConnecting()doesn't restart the timer — so bounding the backoff via channel options is the only public lever that works. Documented in the module header.@grpc/[email protected]+@grpc/proto-loaderadded as desktop-app devDependencies for the test only; the community/production bundle is unaffected (production uses tonic). Root already pins grpc-js to 1.14.4.Verification
Full pre-push gate green (test:all + daemon build + e2e). New regression test + the
startDeferred()recovery test both pass against a real daemon.