Skip to content

fix(orcad): an SSH host launch no longer deletes its own PID file - #52191

Merged
Jinwoo-H merged 2 commits into
mainfrom
fix/orcad-launch-pid-race
Nov 29, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
fix/orcad-launch-pid-race

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When the desktop starts Orca's server on an SSH host, it writes down the server's process number in a file so it can check on it later. Since #51342, a cleanup step that was meant to run before that write could run after it, deleting the file. The server was running fine, but the desktop could no longer prove it, so connecting failed with "Orca couldn't start its server on this host. Try connecting again."

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​67 $\color{#cf222e}{\Huge{\mathbf{−}}}$​22 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​45
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1

Before / after

  • Before: connecting to a fresh Linux SSH host usually failed with the message above, every time. The host had a healthy orcad running and a readiness file, but no .orcad-pid.
  • After: the PID file stays, the liveness check says the server is live, and connect proceeds.

Mechanism

In shell, a && b && { ... } & backgrounds the whole a && b && ... list, not just the last group. #51342 put rm -f "$orcad_pid" inside that list, so it ran in the background, racing the foreground echo $! > pid.tmp && mv pid.tmp pid. The background side has several commands to run first, so it usually lost the race the wrong way and deleted the new file. The removal now runs as its own foreground statement before the chain, which keeps #51342's intent (no stale PID survives a failed write) without the race. The WSL setsid path also gets the earlier removal; it was not affected because it does not background the chain.

Not in any release yet (v1.4.280 predates #51342).

How it was tested

  • Found by the SSH Docker e2e lane being restored for layout-owner work: every SSH journey failed at connect, in both layout modes. Host-side dump showed orcad running (PID present in ps), readiness written, .orcad-pid missing.
  • New real-shell test in orcad-remote-empty-markers.integration.test.ts: runs the generated nohup launch in /bin/sh with a stub slot, waits for its readiness line (written only after exec, so every launch step has run), then checks the PID file names the process and the liveness probe says LIVE. It fails on main and passes with this change. It replaces a test that only checked the command text and asserted the buggy rm -f "$orcad_pid" && form.
  • pnpm tc:node, oxlint, and the file's tests pass locally.

Visible changes

Connecting to an SSH host works again where it showed "Orca couldn't start its server on this host" (unreleased regression).

Performance

None, because the launch runs the same commands; one rm moves out of the chain.

The nohup launch backgrounds its whole && chain, so the PID removal added in
#51342 ran in the background and could delete the PID file the foreground had
just written. The host's server then read as unverifiable and connect failed.
Remove the old PID before the chain instead.
@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Moves PID-file removal before the background launch chain so an SSH launch cannot delete its newly written PID.

  • SSH launches keep the new server's PID file.

No new actionable issues were found. Tests were not run during this review.

Reviews (2) · Last reviewed commit: "test(orcad): a failed PID write leaves n..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The launch command now removes the prior PID file in a standalone command before the chained launch setup. Integration tests check that failed PID writes leave no prior PID marker for both nohup and setsid. A separate test launches a temporary server with nohup, waits for readiness, verifies the PID file and liveness probe, and kills the process during cleanup.

Merge Risk: Minimal · up to fb903

This fixes the SSH launch regression where the PID file could be deleted right after being written, and the new tests exercise the real launch behavior. No remaining merge risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the specific fix: an SSH host launch was deleting its own PID file. The raw summary and description confirm this change: the PID removal moved out of the backgrounded && chain into a s…
Description check Passed The description follows the repository template. It includes ELI5, What Changed (via Before/after and Mechanism), Why, Linked Issue (not present as a 'Fixes #' with a number, but the description refer…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the specific fix: an SSH host launch was deleting its own PID file. The raw summary and description confirm this change: the PID removal moved out of the backgrounded && chain into a standalone statement. The title is specific and matches the main change. It uses a conventional fix(scope) prefix and is 65 characters long.

Full details: Description check

Explanation

The description follows the repository template. It includes ELI5, What Changed (via Before/after and Mechanism), Why, Linked Issue (not present as a 'Fixes #' with a number, but the description references #51342 and the regression, which is a related unreleased regression), Visual Proof (behavior change, but no visual or explicit before/after screenshot; a before/after text description is given), Testing (describes a real-shell integration test and local checks, but does not tick the checkboxes or state platform coverage clearly), Performance (filled in), and Risk (the Risk section and Level are missing entirely). The AI Disclosure and Review sections are absent. The Linked Issue section has a placeholder 'Fixes #' with no number. The Risk section, which is required by the template, is missing. Overall the description is mostly complete but misses the Risk level and backout notes, and leaves the Linked Issue unfilled.

Resolution

Add the Risk section with a Level (Low, Medium, or High), the riskiest part of the change, and how to back it out. Fill in the 'Fixes #' Linked Issue with an actual issue number, or confirm that the linked issue is the one used for the regression. Add the Visual Proof entry, or write N/A with a reason. Tick the Testing checkboxes that apply, and name the platforms tested (for example Linux SSH and WSL).

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5404520f-0a6c-4752-8409-bff253d3a0bd
Commits

Reviewing files that changed from the base of the PR and between 89d53c5 and fb903ed.

Files selected for processing: 1

  • src/main/managed-server/install/orcad-remote-empty-markers.integration.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@Jinwoo-H
Jinwoo-H merged commit 988d891 into main Nov 29, 2026
56 checks passed
Jinwoo-H added a commit that referenced this pull request Nov 29, 2026
…tom; prove every desktop and orcad path

- Known C5 failures no longer mark whole tests. Only one assertion is forgiven, on the new path,
  and only when the page shows the row's symptom (C5-L312: the typed line never reached the shell,
  which ends at an empty prompt; C5-L310: the editor shows the disk file). Any other error still fails.
  L312 loses a race, so a pass is fine; L310 fails when it passes, so a fix drops the mark.
- The job logs each desktop and host orcad's layout path and checks them, as the servers job does;
  browser-routing proves its orcad too.
- The server setting is validated before it reaches the host's shell, and every Docker host and
  volume is removed in its own finally.
- orcad-remote-empty-markers test synced to main's #52191.
Jinwoo-H added a commit that referenced this pull request Nov 29, 2026
…ane (#52103)

* test(layout-owner): run the SSH Docker orcad specs in the switch-on lane

Restores the ssh-orcad journeys (cut 11-21) into the layout-owner suite, passes the
server setting to the Docker host's orcad through sshd, and checks the orcad took it.

* ci(layout-owner): give the SSH lane's orcad template a placeholder phone page

* test(layout-owner): forward app logs from restart launches

* ci(layout-owner): start the SSH lane as soon as the window build is uploaded

* ci(layout-owner): build the orcad template while the window build runs

* test(layout-owner): print the host server's files when an SSH spec fails

* test(layout-owner): list the host slot and processes on SSH spec failure

* ci: retrigger the layout-owner lane

* fix(orcad): an SSH host launch no longer deletes its own PID file

The nohup launch backgrounds its whole && chain, so the PID removal added in
#51342 ran in the background and could delete the PID file the foreground had
just written. The host's server then read as unverifiable and connect failed.
Remove the old PID before the chain instead.

* test(layout-owner): mark the SSH lane's known switch-on failures (C5) and both-mode drift

* test(layout-owner): fit two SSH specs to today's close dialog copy and setup-script prompt

* ci: rerun the layout-owner lane

* test(layout-owner): scope the SSH lane's known failures to their symptom; prove every desktop and orcad path

- Known C5 failures no longer mark whole tests. Only one assertion is forgiven, on the new path,
  and only when the page shows the row's symptom (C5-L312: the typed line never reached the shell,
  which ends at an empty prompt; C5-L310: the editor shows the disk file). Any other error still fails.
  L312 loses a race, so a pass is fine; L310 fails when it passes, so a fix drops the mark.
- The job logs each desktop and host orcad's layout path and checks them, as the servers job does;
  browser-routing proves its orcad too.
- The server setting is validated before it reaches the host's shell, and every Docker host and
  volume is removed in its own finally.
- orcad-remote-empty-markers test synced to main's #52191.

* test(layout-owner): forgive C5-L312 only on a new terminal's first command, and C5-L310 only on the exact disk text

- Lost-keys forgiveness is opt-in at each first-command site, and only counts when the tab was just
  opened by openTerminalTab and nothing else has been typed into it; any expectPaneText consumes it.
  After a reconnect, relaunch, update or sleep, failures stay red.
- The symptom is now a pane holding only its single initial prompt: no echoed input and no output,
  so a command that ran and failed (even a wrapped one) never matches.
- hostCliUntilOk forgives only when no attempt ever got an answer.
- The draft check forgives only when the editor shows exactly the host file's text.
- root-owner's second, managed Open-in-Terminal pane gets the same first-command check.

* test(layout-owner): fix SSH lane CI: no casts, current browser-drop behavior, first-command opt-in for the fault journey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant