Skip to content

fix(pc-install): the restore stops a server it started beside one registered meanwhile, and none of it outlives shutdown - #4959

Merged
devswha merged 3 commits into
mainfrom
fix/restore-start-race
Nov 28, 2026
Merged

devswha merged 3 commits into
mainfrom
fix/restore-start-race

Conversation

@devswha

@devswha devswha commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Two remaining races in the experimental restore of a replaced server (Settings -> Experimental -> PCs, off by default), from the reviews recorded on #3385. The PID-only holder check the issue opened with was already fixed by #3403.

A replacement that registers on another port while the restore runs
The restore's launcher probes only the stopped server's own port. A replacement that came up on another port meanwhile was not seen, so the old server was started beside it. The socket keeps one registration, so the restored server served unregistered beside the replacement, and the job waited out its 3-minute start wait to say it did not start (or, where both registered, said it was restored).
The wait after the launch now looks at every registration on the socket. Once a token not seen before the launch appears, held by another process, it stops the very process it started (its pid and its launch birth) and reports that another already runs in its place.

Shutdown during the restore
The restore's own SSH connection is held by no job, so PcInstaller.stop() could not close it. A first connection still starting when the app stopped was retried, and a restore already waiting kept polling the PC through the teardown. stop() now closes those connections, and a failed start is not retried once the app is stopping.

No UI, setting or HTTP/WS contract change.

Tests

  • New: the restore stops the server it started and says another runs, once another registers on the socket while it starts (fails on main: "did not start within").
  • New: no retry and no kept connection once the app stops, both while the restore's first connection is starting and while it waits for its server (fails on main: the connection was not closed, and a third SSH start happened).
  • The otherRegistersOnRestore case of an existing test is this same race, and now expects "another already runs in its place".
  • bun run check fast passes.

Still open on #3385, all failing safe (no second server is started): a no-birth registration at a reused PID reads as a server (the restore is skipped with a slightly wrong message); the stop wait knows the original by PID and command shape; and the LOW clock-jump case for 0.5.x registrations.

Refs #3385

…istered meanwhile, and none of it outlives shutdown

With the restore on (experimental), a replacement that registers on the
socket on another port while the stopped server is started again was not
seen: the launcher probes only the old port, so the restored server ran
unregistered beside it and the job waited out startMs to say it did not
start. The wait now stops the very process it started (its pid and birth)
once any registration not seen before the launch appears, and says another
already runs in its place.

PcInstaller.stop() now closes the restore's own SSH connections, which no
job holds, and a start that fails once this app stopped is not retried, so
the restore neither opens a second connection nor keeps polling a PC
through the app's teardown.

Refs #3385
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 173ada3 and 8f731d0.

Files selected for processing: 3

  • changelog.d/pc-restore-start-race.md
  • server/pc-install.test.ts
  • server/pc-install.ts
  • 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

@devswha
devswha merged commit e55667b into main Nov 28, 2026
22 checks passed
@devswha

devswha commented Nov 28, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head 8f731d018. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit said it did not review (a limit or a skip) since this head.

main had moved since the checks of 93bcd9195: pr-merge --update merged it in (173ada3cf), and every required check was green at this head.

Reviews: omo gate (CLEAR) + omo-native-code-reviewer (CLEAR; Codex via axwith timed out twice before a verdict). CodeRabbit did not review this head. Lane oi-core-terminal, per the lead's brief.

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