fix(serve): boot probe uses resolvePgserveTransport (matches connection probe) - #1672
Conversation
…on probe) Cosmetic followup to #1667. Pre-this-fix, `genie serve` boot called `requirePgserveDaemon()` which only accepted the canonical Unix socket. On hosts where `pgserve install` registered foreground TCP mode (the supported install path post pgserve@^2.2 — see pgserve/src/cli-install.cjs:225-249), the boot probe printed: Probing canonical pgserve daemon... pgserve unreachable: pgserve canonical daemon is not reachable (no daemon). Recovery: pm2 status # is pgserve registered? pm2 restart pgserve # OR: autopg restart pgserve install # if not registered yet …AND THEN real connections succeeded via the resolver's TCP fallback. Operators read the warning, assumed something was broken, and wasted time on the wrong fix. Diagnosed live during 2026-05-06 dogfood after the user ran `genie update` and saw 141 scheduler errors / 30 min in the diagnostic file (all the pre-#1667 binary's UDS-only probes). Fix: replace the boot probe with the same `resolvePgserveTransport()` the connection layer uses. UDS-first, TCP-fallback. Banner now reports the truth: - UDS reachable: `pgserve ready: unix socket <socketDir>/.s.PGSQL.<port>` - TCP only: `pgserve ready: tcp <host>:<port>` - Both down: `pgserve unreachable: <both-transports hint>` + retry-guard Tests (src/term-commands/serve.test.ts) updated accordingly: - 'boot probe uses the unified resolvePgserveTransport resolver' replaces the legacy `requirePgserveDaemon` source-string lock. - 'boot probe branches on transport.kind for the ready banner' locks the UDS-vs-TCP banner branching. - 'boot probe disables in-process pgserve retries' (renamed from 'serve disables in-process pgserve retries') unchanged in spirit. - Removed 'serve emits the canonical-cutover ready banner on success' — the wording changed; new banner asserted in the kind-branching test. Validation: bun run typecheck ok, bun run lint ok, bun test src/term-commands/serve.test.ts — 19 pass / 0 fail / 71 expects. After this ships, fresh `genie update` + `pm2 restart genie-serve` on a host with foreground-TCP pgserve will show: Probing pgserve transport... pgserve ready: tcp 127.0.0.1:8432 …instead of the misleading "unreachable" warning, with no operator action required. The 141-errors-per-30min scheduler storm in the diagnostic file was already from the pre-#1667 daemon and stops on restart — no scheduler-side change needed in this PR.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the requirePgserveReady function to utilize the unified resolvePgserveTransport resolver, which supports both Unix Domain Sockets and TCP fallbacks. This change fixes a bug where TCP-only installations would trigger a misleading 'unreachable' error message. The associated tests have been updated to reflect this new transport discovery logic. A review comment suggests improving the formatting of multi-line error messages by ensuring consistent indentation when they are printed to the console.
I am having trouble creating individual review comments. Click here to see my feedback.
src/term-commands/serve.ts (635)
The error message returned by resolvePgserveTransport (via buildBothTransportsUnavailableHint) is a multi-line string containing bullet points and recovery steps. When printed directly with a single prefix, subsequent lines will lose their indentation, making the output harder to read and inconsistent with the rest of the boot logs. Indenting all lines of the message ensures the visual structure is preserved.
console.error(" pgserve unreachable: " + msg.replace(/\n/g, "\n "));
Summary
Cosmetic followup to #1667. Pre-this-fix,
genie serveboot calledrequirePgserveDaemon()(UDS-only) and printed a misleading "pgserve unreachable" warning on hosts wherepgserve installregistered foreground TCP mode — even though real connections then succeeded via the resolver's TCP fallback. Operators read the warning, assumed something was broken, wasted time on the wrong fix.What changed
Same retry-guard semantics on failure (both
GENIE_PG_NO_AUTOSTARTenv vars set, no exit). The misleading legacy "Recovery: pm2 status / pm2 restart pgserve / pgserve install" lines drop because the resolver throws a richer message that already mentions both probe attempts and recovery steps.After this ships
Fresh
genie update+pm2 restart genie-serveon a TCP-only host will show:…instead of the noisy "unreachable" warning. No operator action required.
Diagnostic context
While the user was dogfooding the post-#1667 binary, their
~/.genie/logs/update-diagnostics-2026-05-06T15-20-52-347Z.jsonshowed 141 scheduler errors over 30 min: 7 distinct event types (process_cycle_error,agent_resume_timer_error,mailbox_retry_error,heartbeat_error,lease_recovery_error,orphan_reconciliation_error,retention_error), each with the legacy "pgserve canonical daemon is not reachable" hint. Investigation showed those errors were all from the pre-#1667 daemon process still running pre-restart — once the daemon picks up the new code viapm2 restart genie-serve, every error path goes through_buildConnection() → resolvePgserveTransport()and succeeds via TCP fallback. No scheduler-side change needed in this PR.Validation
bun run typecheckbun run lint(2 pre-existing test-fixture symlink warnings)bun test src/term-commands/serve.test.ts— 19 pass / 0 fail / 71 expectsTest plan
devgenie serve→ confirmpgserve ready: tcp ...banner instead of legacy "unreachable" warningpgserve daemonstandalone), confirmpgserve ready: unix socket ...bannerGENIE_PG_NO_AUTOSTART=1set)Related
update-unify-stagesG1-G5 (merged).orphaned_atregression fix🤖 Generated with Claude Code