Repository navigation
fix(viewer): record socket ctime so a replaced socket cannot match - #433
Merged
Merged
Conversation
ext4 gives a freed inode number to the next file in the same directory, so a socket replaced at host.sock usually keeps the recorded ino and dev. host.json now also records the socket ctime in nanoseconds, and requests, stop and launch removal compare it. Readiness from an older host without a ctime never reaches a request, and its dead readiness is removed while the socket stays for the next start to replace. Closes #404
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The native viewer host records the identity of
host.sockinhost.json, and stop, prune, launch removal, requests and pulses use the socket only when it is the recorded one. That check comparedinoanddev. ext4 gives a freed inode number to the next file created in the same directory, so a socket replaced athost.sockusually kept both, and stop or prune could unlink a socket that another process of the same user created there. GitHub runners keep/tmpon ext4, which made the "refuses dead readiness whose socket was replaced" test fail there; PR #400 had weakened that test until this fix.host.jsonnow also records the socket's ctime in nanoseconds, as a string from a bigintlstattaken after the host'schmod. Every check that trustshost.sockcomparesino,devand that ctime, through one helper inviewer-state.ts, still through the directory handle and under the session lock. Ahost.jsonfrom an older host has no ctime, so it is never trusted for requests. When its host is dead, removal deleteshost.jsonand keeps the socket; the next start replaces a leftover socket at that path, so the session is not stuck.Closes #404
inoanddev, as ext4 does404/before-old-source.log,404/after-tests.lognative-viewer.test.tsinoanddevreproduce the ext4 casenative-viewer.test.tsnative-viewer.test.tsnative-viewer.test.tsnative-viewer.test.tshost.jsonremoved, socket kept, the next start replaces it and records its own ctimenative-viewer.test.tsThere is no separate QA pass: nothing user-visible changes, and the live native viewer tests run the real host and viewer.
Sol review: 9/10, no blocker or should. One nit, that the legacy restart test let Node remove the socket before the restart, is fixed in 4f5b2ce, so the leftover socket now stays through the restart.
Checks on 4f5b2ce (before the merge of main, which only brought the test fixes from #430): oxlint, typecheck, build; full vitest coverage run with the desktop, window, wait, browser and viewer requirements on (191 files, 3421 passed, 4 skipped);
PICKFORGE_REQUIRE_XVFB=1 cargo test --workspace --locked(328 passed). PickCheck 0.4.0 against main is clean.