fix(server): harden drain-and-restart spawn failure path (#580 follow-up) - #594
Conversation
Follow-up to lidge-jun#580: wait for detached start spawn success, and on sync throw or pre-start error exit(1) without markRecycling so we never leave a drained process latched or exit(0) with no replacement.
|
Warning Review limit reached
Next review available in: 22 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10c3d236b4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const detail = err instanceof Error ? err.message : "unknown error"; | ||
| console.warn(`⚠️ Drain-and-restart spawn failed (${detail}); exiting without replacement`); |
There was a problem hiding this comment.
Sanitize the spawn error before logging it
When the detached restart fails with errors such as ENOENT, Bun and Node include the executable's absolute path in err.message; because process.execPath commonly contains the OS username, this warning persists an account identifier in console or service logs. Log only a stable error code or sanitize user-specific path components instead of interpolating the raw message.
AGENTS.md reference: AGENTS.md:L98-L99
Useful? React with 👍 / 👎.
| // Listen socket is already stopped; do not markRecycling — no child to inherit fences. | ||
| exitProcess(1); |
There was a problem hiding this comment.
Restore proxy fences before exiting on spawn failure
When the proxy was launched by handleEnsure or the tray's direct-start path, it inherits OCX_SERVICE=1 even when no service is installed, so a spawn failure reaches this branch but syncCleanup skips both restoreNativeCodex() and stripGrokConfig() because that environment marker is still set. Exiting here therefore leaves Codex and Grok configured to use the listener that was just stopped; clear the service marker or invoke explicit failure cleanup before exiting, and add focused coverage for this unsupervised-daemon path.
AGENTS.md reference: AGENTS.md:L93-L95
Useful? React with 👍 / 👎.
Address Codex review on lidge-jun#594: log only errno codes (no pathful messages), and clear inherited OCX_SERVICE on spawn failure so ensure/tray daemons still run syncCleanup restore.
Summary
ocx startspawnsuccess beforemarkRecyclingForExit+exit(0).error, exit1without recycling so a drained process does not stay latched or die with no replacement.Test plan
bun test tests/system-restart.test.tsbun run typecheckbun run privacy:scan