fix(desktop): repair update-mutex path quoting and publish an integer lockfile pid - #96260
fix(desktop): repair update-mutex path quoting and publish an integer lockfile pid#96260SZWzz wants to merge 1 commit into
Conversation
|
A note on CI for reviewers: the |
3cf6ab9 to
6be3344
Compare
This PR fixes two defects in the Desktop remote-lifecycle spawn machinery: it drops the redundant
The sed swap itself is safe: |
|
Thanks for the detailed review. I addressed both hardening suggestions in commit 9691ba2:
Local verification passes:
|
9691ba2 to
c3893f5
Compare
|
text Updated the branch after rebasing onto the latest main (105b865). Refreshed head: c3893f5 |
|
@teknium1 Friendly ping — this PR has been sitting at |
|
Confirming this reproduces on a macOS Desktop client → Ubuntu remote over SSH. Symptom matches #96212 exactly: a literal single-quote directory tree gets created under $HOME on every fresh spawn — $HOME/'/home//.hermes/.hermes-update-in-progress.mutex' The backend connection itself works (the #96084 fix resolved the boot failure), so this is the residual mutex-path double-quoting, not the reservation-site issue. Deleting the tree doesn't help — it regenerates on the next spawn. Both fixes in this PR look correct against what I see live: the shq(mutexPath) removal produces a quote-free argv (previously python3 received '/home//.hermes/.hermes-update-in-progress.mutex' with literal quotes and makedirs/flock hit the bogus path), and the quoted-PID → integer pid swap addresses the malformed-pid fail-closed I was watching for. 👍 Would be great to get this merged |
|
@girishmithran Thanks for the independent confirmation — that is exactly the residual this PR fixes. Your analysis matches the defect precisely: after #96084 resolved the boot hang, With this PR applied, the mutex word is passed raw ( |
|
Update: branch rebased onto current main (
Test coverage grew with it (argv-level assertions pin the single-PID contract and the guard). Local |
…uoting and integer lockfile pid
|
@SZWzz — #104206 carries the Your second concern is real and is NOT covered by #104206: I verified on main that the sh-published record is @girishmithran thanks for the independent repro — that's the residual #104206 closes. |
`apps/desktop/'` is not a real path. It is a literal single-quote directory
holding a full absolute path as nested subdirectories:
apps/desktop/'/var/folders/5h/.../hermes-update-mutex-LMF9y5/home/.hermes-update-in-progress.mutex'
Both files are 0 bytes, nothing in the tree references them, and the leading
and trailing `'` are part of the filenames. They are the fingerprint of the
double-quoted mutex path in `withRemoteUpdateMutex()`: the path reaches Python
with its shell quotes still attached, so it is treated as CWD-relative and
`os.makedirs()` materialises the whole absolute path under whatever directory
the process happened to be in. Running
`apps/desktop/electron/remote-lifecycle.test.ts` from `apps/desktop`
reproduces it on the spot.
They were swept in by a `git add .` in 3662057, an unrelated menu-label
commit.
This only removes the committed artifact. The generator is a separate concern
already covered by open PRs (#99189, #96187, #96260) and issues (#99133,
#96212, #96188); those repair the quoting but none of them deletes these two
files, so the litter would survive whichever one lands.
8a7c60b to
2984920
Compare
|
@kshitijk4poor Rebased onto main after #104206 and removed the overlapping mutex changes. The PR now keeps the PID hardening (integer lockfile PID and scalar detached-spawn PID) plus POSIX dash runtime coverage. Verified with the full Electron test suite (2123 passed, 6 skipped), typecheck, and lint (0 errors). |
Partially superseded: the mutex-path double-quoting half landed on main via #104206. The quoted- |
Follow-up to #96084 (merged as beb212d). That salvage fixed the reservation-site double-quoting and the dash
${var//}bashism; two defects in the same spawn machinery remain on main.1.
withRemoteUpdateMutexstill double-quotes the mutex pathremote-lifecycle.ts(main, line 916):Both call sites pass
expandRemotePath(...)output, somutexPathis already a complete shell word and the extrashq()stores the quote characters literally — the same defect class #96084 removed at the reservation sites. As @deepanaishtaweera demonstrated on #96084 by shim-capturing argv from the realbuildSpawnCommandoutput, the remote python thenmakedirs/flocks a bogus$HOME/'tree instead of the real sidecar (reproduces the #96212 stray tree): a mutex that silently serializes nothing, with no boot symptom. Verified again here after the fix:argv[3]is now the single quote-free word$HOME/.hermes/.hermes-update-in-progress.mutex.2. The sed placeholder swap publishes a quoted-string pid
#96084's POSIX swap replaces the bare
__PID__inside the JSON-quoted"pid":"__PID__"template, so the initial lockfile carries"pid":"4242"(string). Downstream:readLockfile()requiresNumber.isInteger(parsed.pid)— a client crash between the payload write and readiness leaves amalformed-pidrecord that fails closed (remote-lockfile-skew, no reap/respawn) on the next connect;"pid":\([0-9][0-9]*\)only matches an unquoted number.This PR replaces the quoted placeholder (
sed "s/\"__PID__\"/${child}/"), publishing a real JSON integer.Regression coverage
assert.ok(cmd.includes(...))+assert.doesNotMatch(cmd, /'"\$HOME"'/)) — the previous substring assertioncmd.includes('.hermes-update-in-progress.mutex')matches both the broken and fixed forms.Test plan
remote-lifecycleunit tests pass (npx vitest run electron/remote-lifecycle.test.ts)dash -n; mutex argv verified quote-free by shlex-splitting the realbuildSpawnCommandoutputserve --isolatedalive,backend.lock.jsonpublished,Remote Hermes backend is ready(reported on fix(desktop): fresh managed-SSH spawns no longer wedge on dash or double-quoted paths (salvage #96061) #96084)Refs #96188, #96212. Previously surfaced in the discussion on #96084 and in the (closed duplicate) #96189.