Repository navigation
Server: a second receiver on the same state folder no longer deletes the first one's run.json - #270
connorburgess wants to merge 3 commits into
Conversation
…the first one's run.json Symptom: with receiver A running, a second receiver B started with the same --state and another --port, then stopped with Ctrl-C or SIGTERM, left no run.json although A still answered on its port. `service status` then printed "run.json none", and the desktop app, which reads run.json after probing the default port, no longer found an A that was not on 7373. Cause: B overwrote run.json when it started listening, and on a clean stop removeRunFile deleted it because the file named B's pid. Nothing remembered the entry B had replaced. Fix: at listen the receiver reads the live run.json it is about to replace. On a clean stop (signal or exit), if run.json still names it and the receiver it replaced still runs, it writes that entry back atomically instead of removing the file; otherwise it removes its own as before. removeRunFile is unchanged for its other callers. writeRunFile no longer leaves its temporary file behind when the write or the rename fails. Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>
Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>
|
The second receiver run.json restoration fix still applies to SessionPipe GUI v0.8.18. Merged current Resolved the changelog conflict by retaining the new release sections and this fix under Unreleased. Validation on this head, macOS / Node 22.23.2:
GitHub CI run 47453784594 for head The desktop shard 3 failure is d16a2c01, npx playwright test test/e2e/split.spec.ts --project=desktop --grep "covering the page locks" --repeat-each=6 --workers=2 reproduced four first-attempt failures; all four passed on retry, with two other repetitions passing initially. This establishes baseline flakiness, but does not turn the failed PR run green.
A maintainer needs to rerun the failed job (and aggregate gate), or resolve the baseline flake, before merging. The job-rerun API rejected this account with HTTP 403: “Must have admin rights to Repository.” |
Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>
|
Merged current CI run 47497350179 for head The earlier run 47453784594 on Locally on |
Updated against v0.8.19 / main
e8bfe999on 2026-12-05. Current validation and refresh details.What
When two receivers share one state folder (the second started with another
--port), stopping the second one no longer deletesrun.jsonwhile the first still runs. The stopping receiver writes back the entry it replaced at listen, soservice statusand the desktop app (which readsrun.jsonafter probing the default port) still find the first receiver.Why
server/app.tssupports two receivers on one state folder, andserver/runfile.tsalready says a second receiver "must not delete the first one's" file. But the second receiver overwritesrun.jsonwhen it listens (server/cli.ts,writeRunFile), and on a clean stopremoveRunFiledeletes it because the file now names the second receiver's pid. Steps onmain(1a475e8):node dist/cli.js --state S --port 47811 --quiet --demo(receiver A)node dist/cli.js --state S --port 47812 --quiet --demo(receiver B):S/run.jsonnow names BS/run.jsonis gone, whileGET http://127.0.0.1:47811/api/ui/infostill answers 200.sessionpipe-gui service statusprintsrun.json none.Fix
server/runfile.ts: newreleaseRunFile(stateDir, previous). Ifrun.jsonstill names this process and the receiver it replaced (previous) is still alive, it writes that entry back atomically throughwriteRunFile. Otherwise it removes our own file, exactly asremoveRunFiledoes. If the file names someone else, it leaves it alone.removeRunFilekeeps its contract and return value for its other caller, the Windowsservice stopinserver/service/index.ts.server/cli.ts: at listen, read the liverun.json(readRunFile) before overwriting it. The signal shutdown and theexithandler both callreleaseRunFile. Whenexitruns after the shutdown, the file no longer names us, so it does nothing.writeRunFilenow removes its temporary file when the write or the rename fails, instead of leavingrun.json.<pid>.tmpin the state folder.What it does not cover:
run.json, onmainor here. A receiver that starts in the instant another is stopping can still lose its entry, the same windowremoveRunFile's read-then-delete has onmain.run.json.Original proof (before the v0.8.18 refresh)
Two new lifecycle tests in
server/runfile.test.ts(a second receiver stopped by SIGTERM/SIGINT gives run.json back to the first, still running), next to the existing SIGTERM/SIGINT/SIGHUP ones. Each starts two CLI receivers on one state folder, stops the second, and checks thatrun.jsonequals the first one's entry and that the first still answers. A control test stops the first one first; the second one's file stays and is removed when it stops. Unit tests coverreleaseRunFile's branches (previous alive, previous gone, no previous, file not ours, write-back failing) and the temporary file on a failed rename.The two lifecycle tests on
main's code (test file only), output trimmed:On this branch:
Run on macOS only. Not run on Windows.
Checklist
git commit -s): the DCO is the only paperwork.npm run typecheck && npm run lint && npm testpass;npm run test:e2efor a UI change. (No UI change.)// SPDX-License-Identifier: Apache-2.0. (No new files.)--demo).shared/*names the wire-contract change in the description. (Noshared/*change.)CHANGELOG.mdif a person would notice.