Repository navigation
fix(update): release an interrupted Windows update marker once its supervisor is gone - #8534
Conversation
…pervisor is gone An interrupted Windows update left update-orchestrated.json with terminationUnconfirmed and no process-tree witness, because only the POSIX supervisor records installerPid/installerPgid. inspectUpdateMarker then answered "unknown" forever and every later update and sync refused with update-in-flight (#8524). The Windows installer runs in a kill-on-close Job Object whose only handle lives in its PowerShell supervisor, so the supervisor pid is the Windows witness. runNpmInstall now records it in the marker before the supervisor receives its request; inspectUpdateMarker frees an unconfirmed Windows marker once that pid and the fence are gone, and ignores the pid once the exit is confirmed. A supervisor that cannot be recorded gets no request and reports an unstarted installer; a live earlier supervisor keeps its witness. Closes #8524
|
✅ Deterministic PR hygiene checks passed. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Caution Review failedThe pull request is closed.
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. |
Maintainer judgment (bundle lane: service / platform / link diagnostics)Value. An interrupted Windows update no longer blocks every later UX change. None on the success path. On Windows, an interrupted update now clears itself after the fence. Two new refusals are both fail-safe:
Existing users. POSIX behavior is unchanged: same probe, same Windows impact. The witness is sound because
Verification.
NOT RUN.
Owner decision (not implemented). Markers that already exist without
Closes #8524. |
The Windows supervisor tests loaded a data: URL copy of npm-install.mjs that pinned only ./mutation-guard.mjs, so the relative imports #8534 added could not resolve; a shared loader now pins every relative ./*.mjs import and a cross-platform case loads the copy on every host. #8534's win32 rule that skipped a recorded installerPid unless terminationUnconfirmed is reverted; confirmInstallerExit already drops the Windows witness. Refs #8524
Summary
On Windows, an interrupted
ocx update(console closed, Ctrl+C, Task Manager, sleep or power loss after "Service manager stopped") leftupdate-orchestrated.jsonwithterminationUnconfirmed: trueand no process-tree witness. Every laterocx update,ocx syncandocx update --plan --yesthen failed withupdate-in-flight, permanently (#8524).inspectUpdateMarkerfrees an unconfirmed marker only throughinstallerPgid, and only the POSIX supervisor ever writes it.The Windows installer runs inside a private kill-on-close Job Object (
npm-install-job.ps1). Breakaway is not allowed, the job handle is never inherited, and its only handle lives in the PowerShell supervisor. When that supervisor process is gone, the job is closed and its tree terminated. The supervisor pid is therefore the Windows counterpart of the POSIX process group.runNpmInstallrecords the supervisor pid asinstallerPid(newsrc/update/windows-installer-marker.mjs) before writing the supervisor's stdin request. The supervisor creates no job or installer until stdin closes, so a launcher killed after the publish leaves a marker whose witness is the supervisor itself.runWindowsInstallerSyncforwardsmarkerPath, and all four session call sites passjoin(configDir, "update-orchestrated.json").inspectUpdateMarkerfrees an unconfirmed Windows marker onceinstallerPidand the launcher pid are gone and the fence has passed. On Windows it readsinstallerPidonly whileterminationUnconfirmedis set, so a finished update never reads as in flight because Windows reused the supervisor's old pid. POSIX behavior is unchanged.confirmInstallerExitdrops a Windows-shaped witness (installerPidwithoutinstallerPgid), so a pnpm rollback, the second installer run in one session, can record its own supervisor.status: 1, processTreeExited: trueafter its close. The caller then confirms the exit instead of recreating the stuck marker.processTreeExited: false).Not covered (owner decision). A marker that already exists without
installerPid, written by 2.100.x or earlier like the reporter's file, still readsunknown. Releasing it on fence and launcher pid alone would also release a supervisor suspended across sleep. Options are in the Maintainer judgment.Accepted residuals.
setsid.Closes #8524
Verification
New
tests/update/update-windows-installer-witness.test.ts, 12 cases, with the platform and the supervisor launcher injected:runNpmInstallrecording the pid before the request is written;Fail-first: with
sync-update-mutex.mjsandorchestrated-session.mjsreverted to dev, the four core cases fail. These are the reporter's shape, live and unknown handling, legacy-marker handling, and the rollback run.bun test tests/update: 1038 pass, 1 fail. The failure isupdate-orchestrated-entry"npm child fences identity…", which took 28.8 s under host load and passes alone (32.4 s).bun run typecheck,bun run privacy:scan,bun run structure:check(structure/ops/service-and-sidecars.mdedited in place), the test-layout guards, the file-size ratchet and the Lab boundary all pass.The data-reading update lint contracts were updated by hand: the
child.kill()count from 2 to 3, the bridge input string, rows for the new module's primitives, and import policy. Their parser-backed tests skip on POSIX hosts (Bun cannot start the TypeScript sync client there), so only the Windows lane exercises them.NOT RUN:
bun run test:changed: on this loaded host (load average about 9 from other lanes) it times out unrelated server e2e files. CI's Linux shards cover it.Checklist