Repository navigation
fix(windows): stop an old-id server that outlived herdr, re-read the PC on Try again, show the QR with a token and a readable log (#2264) - #2275
Conversation
…PC on Try again, show the QR with a token and a readable log (#2264) - install.ps1 and the app run the old id's plugin.ts with herdr's state dir (HERDR_PLUGIN_STATE_DIR), where releases before 0.4.13 keep their pid; a stop that finds no server there asks again without it. - Try again after a failed Update reads the PC again instead of the removed checkout, and finishes the update's last steps for a current server. - GET /api/access gets the PC's own token that opened GET /api/updates; a token it cannot use is named instead of "install Tailscale". - The installer runs with -Command, not -EncodedCommand, so Windows PowerShell writes plain lines instead of CLIXML. Closes #2264
|
Warning Review limit reachedYou'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 7 minutes. View limit details
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. Comment |
|
CodeRabbit hit its review limit on this PR ("Review limit reached"), so no CodeRabbit review ran. This PR sends a token to an HTTP endpoint and changes the installer path, so the code-review agents' reviews stand in. Their findings and how each was resolved, all on the head before omo-native-code-reviewer (one round): VERDICT PASS, no CRITICAL/HIGH/MEDIUM. Four LOWs, all fixed in
Codex (gpt-6.1-sol, fast, xhigh), four rounds:
Verification on |
|
|
|
CI note: "Browser regression (other scripts)" was cancelled at its time limit in all three attempts of run 40704268690 (51-52 min each), with no failing script. Attempt 3 (runner This PR changes only |
…r-fit timing out under load (#2287) Closes #2285 ## What was wrong `Browser regression (other scripts)` kept ending as cancelled at its 50-minute `timeout-minutes`. It looked like hung demo scripts, but no script hung. Each job waited a long time for a herdr check slot (`scripts/check.ts`, `check: took a slot after Ns`) and then ran the lane until the job timeout stopped it: | job | PR | slot wait | lane before the cancel | | --- | --- | --- | --- | | 122862337418 | #2266 attempt 1 | 1340 s | finished, 107/108 in 1238 s (a real `file-viewer-regression.ts:1395` failure) | | 122889113275 | #2266 attempt 2 | 2110 s | 14 min, cancelled | | 122878703515 | #2260 | 1755 s | 20 min, cancelled | | 122872125320 | #2275 | 1635 s | 22 min, cancelled | The scripts that "STARTed and never finished" were the ones running at the cancel. Their logs in the browser-logs artifact print `PASS` lines up to the cancel second. For example, `sidebar-activity-demo-regression.log` ends with a PASS at 15:35:59, the same second as `##[error]The operation was canceled.` The longest single script run in these jobs was 357 s. `ci.yml` gives these jobs `timeout-minutes: 50` and `CHECK_WAIT_SECONDS: 2400`, and time spent waiting for a slot counts against the timeout. On 2026-10-28 the P620 had 20 runners queuing for 4 slots (`CHECK_HOST_MAX_RUNS=4`), and waits reached 37.6 min. ## What this PR changes `scripts/ci-browser-parallel.ts` now limits each run of a script to `BROWSER_SCRIPT_TIMEOUT_SECONDS` (default 600 s, about twice the slowest run seen on a loaded host). Before this, a script that really hung, or a process it started that kept its output open, would have used up the whole job. Past the limit: - the script's whole process tree (read from `ps` before anything is signalled, so Chromium and servers it started are included) gets SIGTERM, then SIGKILL after 5 s; - the lane prints `TIMEOUT <script>` and the script's last 40 log lines straight away; - the script fails with exit 124 and is not run a second time; - the summary, `summary.json`, the `::error` annotation and the job summary all name it with `Timed out after Ns`. It also fails a script that exits but leaves a process holding its output open: if the output is still open 5 s after the exit, the run fails with `Exited N, but a process it started still held its output`. A run's processes carry a mark in their environment, so the stop finds them through `/proc` on Linux even after they are moved to init. Anything still alive after the SIGTERM grace gets SIGKILL, including a child that ignores SIGTERM and writes nowhere. The script's own pid is only signalled while the script is still running. `scripts/composer-fit-demo-regression.ts:278` gave `setInputFiles` a 32 MiB + 1 byte buffer. Playwright sends a buffer to the page as base64 (about 45 MB), which on a loaded host ran past the 30 s timeout. That is a real load failure inside this job: it failed twice in #2260's job and twice in a row locally at load 80-110. It now passes a sparse file of the same size by path. Chromium reads only its size, and the app still refuses it by size (`src/lib/api.ts`) before reading. `docs/development.md` documents the setting and says to check the slot wait first when a job is cancelled at its timeout. No workflow file is changed. ## Done outside this PR - Host (Dori's call): the P620's runner count goes from 20 to 8 (2 reserved for main, 6 for PRs), with `CHECK_HOST_MAX_RUNS=4` kept. With 4 slots, at most 4 jobs can wait, so in the worst case a job waits one slot round (about 20 min) and then runs the lane (about 21 min), within 50 min. Jobs beyond that now queue at GitHub, which does not count toward `timeout-minutes`. - Proposal for the owner, not applied: `timeout-minutes: 50` -> `75` for Integration tests, Browser regression (ui-regression) and Browser regression (other scripts), so the 40-minute `CHECK_WAIT_SECONDS` budget and the lane both fit inside the job. ## Verification - `bun test scripts/ci-browser-parallel.test.ts`: 4 pass. The two deadline tests fail on the runner before this PR: the hung stub runs into the test's 15 s spawn limit, and the exit-but-holding stub is never caught. - The real runner on a hung stub that leaves a child holding stdout, with `BROWSER_SCRIPT_TIMEOUT_SECONDS=2`. Before this PR it still showed only `START` when the outer bound killed it at 30 s, and the child was left alive. With it, the run exits 1 after 2.4 s, with `TIMEOUT`, the script's last lines and exit 124, and the child is gone. - A child that ignores SIGTERM and writes nowhere. It survived the first commit of this PR (Codex's HIGH) and is killed by the second. - The six scripts named in the issue, run through the parallel runner with 6 workers and `BROWSER_RETRY=0` under `dori heavy` on a host at load 60-110: - with the composer-fit fix: 6/6 in each of three runs (359 s, 334 s, 320 s); - before it: 5/6 twice, both times composer-fit failing with `setInputFiles` timing out at line 278. The other five scripts passed every time. None hung, and none was reported STOPPED with real Chromium. - `bun run check fast` on 72d6486: typecheck, build, and unit tests (8250 pass, 0 fail). - Reviews: - omo-native-code-reviewer: PASS, with one MEDIUM (a script that exits but leaves a process holding its output) that is now fixed. - Codex Sol 6.1 fast xhigh: first review BLOCK, on a HIGH (a child ignoring SIGTERM survived), two MEDIUMs (re-parented children, stale pids) and one LOW (zombies in the test). All were reproduced and fixed, and the re-review is a PASS. Known limits it names: on Linux, orphans are found through `/proc`, and a narrow pid-reuse race remains between reading and signalling. - The composer-fit change (test only) had no separate reviewer.
|
Merging 5df2937 (closes #2264). Codex was at capacity, so an omo reviewer and an independent second reviewer on the Windows PC reviewed it. The old-id stop runs the old checkout's plugin.ts with HERDR_PLUGIN_STATE_DIR set to herdr's state dir for that plugin, passed as environment data, not interpolated into PowerShell, and restored in finally; the fallback runs at most once, only after a successful stop that stopped nothing. The old releases' stop still checks the process (Bun executable, that checkout's server/managed.ts, creation time against the pid file) before taskkill, so a stale pid file pointing at another process is left alone. Try again re-reads the plugin list first and prefers the new id, so it never runs the deleted checkout. The token stays in memory and in the Authorization header (never on a command line, URL, QR or log); a 401 from /api/access now says the access is locked instead of telling the PC to install Tailscale. The log uses plain -Command, with no output filtering. On the Windows 11 PC the second reviewer reproduced case 1 with the real 0.3.45 server in an isolated profile: the main-style stop said 'not running', this head's stop stopped it; a stale pid record pointing at an unrelated Bun process was refused and that process left alive; the token opened /api/access in a real Model.ReadStatus run and a wrong token set AccessLocked. windows-install.test.ps1, the app tests (20 pass) and both app builds passed there too. CI at this head: the Windows app tests (20 pass, incl. the state-dir and real PowerShell cases), the native installer regression with the new legacy-state case, and a real install of 0.4.19 with herdr 0.9.5 pass. Not filed: the readable-log test starts powershell.exe directly instead of through Run.Program (app/windows/tests/SetupTests.cs ~222-249); UpdateAgain's retry paths have no automated test (Model.cs ~181-194, covered by the PR's manual VM run). |
Closes #2264
Problem
Testing the Windows app's Update for an older server (#2091, #2113) in the Windows 11 VM, with
Ovis.exe0.4.19 anddevswha.herdr-web-ui0.3.45 installed under the old id, found four problems (reproduced again on main 9a44f27 before this change):scripts/plugin.ts stopoutside herdr. Releases before 0.4.13 read their pid fromHERDR_PLUGIN_STATE_DIRand, without it, from~/.local/state/herdr-web-ui, while herdr keeps it in%LOCALAPPDATA%\herdr\plugins\devswha.herdr-web-ui\server.pid. The stop said "not running", install.ps1'sherdr plugin uninstall devswha.herdr-web-uifailed withOs { code: 32 }, and the half-deleted checkout kept serving 0.3.45 on 7317 under a herdr list that names onlydevswha.ovis.error: Module not found ...devswha.herdr-web-ui-210f619d6b7b\scripts\plugin.ts, shown as "Could not stop the Ovis server").GET /api/accesswas read without the token, answered 401, and the app told a PC that runs Tailscale to install it.#< CLIXML <Objs ...>).Change
install.ps1,Model.PluginCommand): the old id'splugin.ts(stop, status, phone) runs withHERDR_PLUGIN_STATE_DIRset to herdr's state dir for the plugin, found asscripts/plugin-state.tsfinds it (XDG_STATE_HOME, else%LOCALAPPDATA%), and restored afterwards. A stop that finds no server there runs once more with the original environment, so a server started by hand from the old checkout (pid in its own dir) is still stopped. Every new-id release (0.4.14+) finds herdr's dir by itself and is run as before.GET /api/updates(the PC's own, from the plugin'senv/.env, as before) is sent toGET /api/accessat the same origin. When that still answers 401 the app says the token is missing or did not work, instead of "install Tailscale".portandserving_urlinGET /api/updatesare given only to the connection server's bridge token, which this app does not hold, so they cannot replace this; the app's own token already opens/api/access, which also tells Tailscale's state (needed for "Make the phone address" and "Sign in to Tailscale"). No server change.-Commandinstead of-EncodedCommand. In the VM, Windows PowerShell 5.1 started with-EncodedCommandand redirected output wrote progress, warning and error records to stderr as CLIXML whatever-OutputFormatand stdin were;-Commandwrites the plain lines.Runhands the script to cmd in an environment variable, so its|and quotes arrive as written.Tests
scripts/windows-install.test.ps1: the old id's stop is told herdr's state dir (with and withoutXDG_STATE_HOME), the variable is not left set, and a stop that finds no server there asks again without it. Fails on main's install.ps1 ("The old id's stop must look for its pid where herdr keeps the plugin's state"), passes with this change (VM, desktop session).app/windows/tests(Ovis.Tests.exe): the state dir, the phone step for a token the app could not use, and a real Windows PowerShell run with the app's arguments that must print host, warning and error lines without CLIXML. 20/20 pass in the VM; the PowerShell case fails with main's-EncodedCommandarguments.bun run check fast: green.Manual QA (winvm, Windows 11, herdr 0.9.3, Bun 1.4.2;
Ovis.exebuilt at version 0.4.19)Setup each time:
winvm reset(dev-ready-4),herdr plugin install devswha/herdr-web-ui --ref v0.3.45, aHERDR_WEB_TOKENand a marker line in itsenv,herdr server, then herdr alone ended (taskkill /IM herdr.exe /F): the 0.3.45 server keeps running.devswha.ovisdevswha.ovis0.4.19,/api/updatessayscurrent_version 0.4.19, no old process or checkout, env marker and token moved, Run value sethttps://winvm.example.ts.netModule not found ...devswha.herdr-web-ui-...\scripts\plugin.tsherdr failed (exit 1)as plain lines; Try again reads the PC again and lands on Running on this PC (devswha.ovis0.4.19), noModule not foundScreenshots
main:

this change:

Reviews
[IO.Path]::Combinefor an emptyXDG_STATE_HOME; the PowerShell test waits with a bound).-Commandswitch) PASS with no findings.Not in this PR (LOW, pre-existing)
check fastonce failedscripts/self-hosted-runner.test.ts("the stub never hung") under load; it passes alone on this branch and on main (30/30), and a rerun of the whole check was green.