Skip to content

fix(server): harden drain-and-restart spawn failure path (#580 follow-up) - #594

Merged
Wibias merged 2 commits into
lidge-jun:devfrom
Wibias:fix/580-restart-spawn-failure
Jul 28, 2026
Merged

fix(server): harden drain-and-restart spawn failure path (#580 follow-up)#594
Wibias merged 2 commits into
lidge-jun:devfrom
Wibias:fix/580-restart-spawn-failure

Conversation

@Wibias

@Wibias Wibias commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Follow-up to feat(dashboard): drain-and-restart from memory observability card (#563) #580 / issue-author note: wait for detached ocx start spawn success before markRecyclingForExit + exit(0).
  • On sync spawn throw or pre-start error, exit 1 without recycling so a drained process does not stay latched or die with no replacement.
  • Adds regression coverage for sync throw and async rejection paths.

Test plan

  • bun test tests/system-restart.test.ts
  • bun run typecheck
  • bun run privacy:scan
  • CI green on Linux/Windows/macOS

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.
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Wibias, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 22 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b385ae94-564e-4fc1-a879-2125e66ea839

📥 Commits

Reviewing files that changed from the base of the PR and between 903b62c and 2bdb7a8.

📒 Files selected for processing (2)
  • src/server/management/system-restart.ts
  • tests/system-restart.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Jul 28, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/server/management/system-restart.ts Outdated
Comment on lines +139 to +140
const detail = err instanceof Error ? err.message : "unknown error";
console.warn(`⚠️ Drain-and-restart spawn failed (${detail}); exiting without replacement`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +141 to +142
// Listen socket is already stopped; do not markRecycling — no child to inherit fences.
exitProcess(1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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.
@Wibias
Wibias merged commit e545512 into lidge-jun:dev Jul 28, 2026
9 checks passed
@Wibias
Wibias deleted the fix/580-restart-spawn-failure branch July 28, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant