Repository navigation
Establish one daemon-readiness contract to stop per-call-site startup races - #1552
Conversation
…aemon (closes #1525) daemon-status.ts consumed only the pushed daemon-status Tauri event, which raced the webview's own listener registration and never re-fired after startup — an unattended daemon recovery had no signal path, and the Retry button bypassed the shared store entirely with its own ad-hoc invoke() call. Redesign it around a transport-agnostic status source that pulls the current status on subscribe (closing the lost-first-event race) in addition to consuming pushed events, and give Retry a real path through the shared contract via the new refreshDaemonStatus(). Add integration coverage that was previously entirely absent: a Rust test that spawns a real headless nodespaced and proves the readiness contract (check_daemon_socket/wait_for_daemon and the real check_daemon_status command body) against it, and a TypeScript e2e test that proves a daemon-dependent store genuinely fails while the daemon is down and self-heals with real data once it's reachable — using the existing DaemonTestHarness, extended with a startDeferred() variant that doesn't block on daemon readiness. Co-Authored-By: Claude <[email protected]>
The 5s poll window for the reconnect-triggered load to land was too tight under contention (observed failing once under the pre-push hook, right after a fresh cargo build left the machine busy) — widen it to 20s and surface a real diagnostic (a direct getAllSchemas() call) if it still times out, instead of a bare "expected 0 to be > 0". Co-Authored-By: Claude <[email protected]>
Debugging an intermittent failure under pre-push load surfaced a second readiness layer distinct from the daemon's socket: DaemonTestHarness. startDeferred() starts the dev-proxy before the daemon binds its socket, and the proxy's gRPC-js client — constructed once at proxy startup against a not-yet-existing socket — owns its own reconnect/backoff state independent of the daemon's actual socket becoming reachable moments later. A store reload triggered right as the socket became reachable could fail silently against a proxy channel still mid-backoff. Add waitUntilProxyReady(), which polls a real data-plane round-trip (HTTP -> dev-proxy -> gRPC -> daemon) instead of just the socket, and use it in the readiness e2e test. Verified separately (scratch Rust test, not committed) that production's tonic lazy channel does NOT have this gap — a call issued right after the daemon binds succeeds immediately, no cached backoff state. This is specific to the gRPC-js dev-proxy path used only by this test harness. Follow-up issue to be filed for that gap on its own. Co-Authored-By: Claude <[email protected]>
Code Review SummaryNet positive, well above the bar for this repo. This closes a real, previously-unrecoverable startup race (lost first Nothing here blocks merge. Two findings worth a look, one is genuinely dead code. FindingsSuggested Improvements
Nitpicks
Process note (not a blocker for this PR)
|
- Add a Drop-based EnvGuard for the Rust integration test's NODESPACED_SOCKET mutation, so a panicking assertion can't leak the mutated env var to whichever test acquires ENV_MUTEX next (the manual save/restore only ran on the non-panicking path). - Remove daemon-harness.ts's waitUntilDaemonReady(), left as dead code after its only call site was replaced by waitUntilProxyReady() (which waits on the real data-plane round-trip, not just the daemon's socket). Co-Authored-By: Claude <[email protected]>
|
Addressed both fixable review findings in 6d6a615:
Not addressed (both explicitly called non-blocking, and out of this issue's scope):
Full test suite + pre-push gate re-verified green after these changes. |
Closes #1525