fix(daemon): surface detached launch failures to callers - #351
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Wait for process creation in explicit starts and automatic launches so spawn failures report the executable and original OS error without a readiness timeout. Keep late child errors handled and retain authenticated readiness after spawn. Prove real ENOENT propagation through both callers, cover launch ordering and late errors, and document the behavior under the 0.13.10 release notes. Co-authored-by: Sebastien Tardif <SebTardif@ncf.ca>
|
Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 4:24 PM ET / 20:24 UTC. ClawSweeper reviewWhat this changesMake explicit and automatic daemon starts report process-creation failures immediately, with the executable, original OS error, regression coverage, and documentation. Merge readiness✅ Ready for maintainer review This PR remains useful: main prevents the crash but still discards the launch error. No actionable correctness findings remain, and the verified test merge resolves the previous conflict concern. Priority: P2 Review scores
Verification
How this fits togetherMCPorter’s daemon keeps MCP server connections alive across CLI invocations. Explicit starts and automatic launches create the background process, then verify authenticated readiness before using it. flowchart TD
A[Explicit daemon start] --> C[Detached process launch]
B[Automatic daemon launch] --> C
C --> D{Process created?}
D -->|No| E[Return executable and OS error]
D -->|Yes| F[Authenticated readiness check]
F --> G[Ready daemon or diagnostic timeout]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Preserve immediate process-creation diagnostics while retaining authenticated readiness and its existing timeout for successfully spawned processes. Do we have a high-confidence way to reproduce the issue? Yes, from source: a missing launch executable on main has its error discarded, after which callers enter readiness polling. The PR adds real-process regression cases; this read-only review did not execute them. Is this the best way to solve the issue? Yes. Awaiting process creation in the shared helper and both callers is a narrow repair that preserves successful-launch readiness and existing security checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7a2d4dc563c9. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
63f288c to
e3292d8
Compare
Supersedes #347, keeping @SebTardif's original commit and sign-off at the base of this branch.
Problem
launchDaemonDetachedspawned the daemon with{ detached: true, stdio: 'ignore' }and calledunref()without anerrorlistener. Node emits spawn failures (ENOENT and friends) asynchronously, so a missing launch command — stripped PATH, missingnohupon a compiled macOS binary, a deleted Node entry — became an unhandled'error'event that killed the parent CLI. This is the same defect class as #341 foropenExternal.What changed beyond the original fix
@SebTardif's commit attached the listener, which stopped the crash but swallowed the cause: callers then sat through the full readiness timeout with no indication of what failed.
launchDaemonDetachednow awaits process creation and resolves on'spawn'or rejects on'error', wrapping the failure with the executable and the original OS error ascause. Both call sites —mcporter daemon startandDaemonClient.ensureDaemon()auto-launch — await it, so a launch failure is reported immediately instead of masquerading as a readiness timeout. The'error'listener stays attached after a successful spawn so a late error still cannot become an unhandled event.Authenticated readiness, its 45-second timeout, the foreground logging guidance, and the 0.13.9 single-user ownership safeguards are unchanged. Other daemon and relay spawn sites were checked and already handle errors.
Verification
pnpm checkclean.pnpm test: 1867 passed, 26 existing skips, 218 files. New tests cover real ENOENT failures through both callers, spawn ordering, and repeated late errors. No timeouts, CI budgets, or skips were changed.