Repository navigation
fix(desktop): tolerate a broken TCP state column in the Windows listener check - #26
Open
rajnishmanitiwari wants to merge 1 commit into
Open
rajnishmanitiwari wants to merge 1 commit into
rajnishmanitiwari wants to merge 1 commit into
Conversation
…ner check On some Windows builds the OS reports a listening socket with a wrong or empty TCP state (0, 1, 6, or unmapped), so the owner check's State = 2 predicate matched 0 rows even though the socket was listening and accepting connections. Startup then failed every time with listener_missing and the GUI blamed machine load. The listener query no longer filters on State: a row for the port owned by the process proves the bound socket, and rows owned by anyone else are tolerated as long as one row is ours. The token-authenticated handshake in connectBackground remains the identity proof, and a query returning no rows at all still reports listener_missing. Fixes w01fb0ss#15. Tests: new windows-background-security.test.ts pins the query and the row-matching order; 3 of its 5 tests fail against the old script. Full apps/desktop suite 108/108 pass; package typecheck and Biome clean. Signed-off-by: Rajnish Mani Tiwari <76885104+rajnishmanitiwari@users.noreply.github.com>
w01fb0ss
requested changes
Nov 26, 2026
w01fb0ss
left a comment
Owner
There was a problem hiding this comment.
Thanks — this is a real startup blocker on Windows 26300 (#15), and dropping the State = 2 filter is the right fix: the state column isn't identity evidence.
One change before merging: please keep rejecting rows owned by other processes. The client sends its token as the first message, so the pre-connect owner check is what stops a second listener on the same loopback port from receiving it. A TIME_WAIT leftover from a dead predecessor is reported as owned by the System Idle/System process (0 or 4), so tolerating those is enough:
$foreign = @($listener | Where-Object { $p = [int]$_['OwningProcess']; $p -ne $processId -and $p -ne 0 -and $p -ne 4 })
if ($foreign.Count -gt 0) { throw 'listener_identity_changed' }
if (@($listener | Where-Object { [int]$_['OwningProcess'] -eq $processId }).Count -eq 0) { throw 'listener_identity_changed' }plus a test for "another process owns a row → rejected". I'll approve the CI run now.
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.
Fixes #15. On some Windows builds the OS reports a listening socket with a wrong or empty TCP state (0, 1, 6, or unmapped), so the owner check's State = 2 predicate matched 0 rows even though the socket was listening and accepting connections. Startup then failed every time with listener_missing and the GUI blamed machine load. The listener query no longer filters on State: a row for the port owned by the process proves the bound socket, and rows owned by anyone else are tolerated as long as one row is ours. The token-authenticated handshake in connectBackground remains the identity proof, and a query returning no rows at all still reports listener_missing. Note: the GUI still shows the generic load message for a launch timeout; surfacing the check code to the user is a separate follow-up, not in this PR. Tests: new windows-background-security.test.ts pins the query and the row-matching order; 3 of its 5 tests fail against the old script. Full apps/desktop suite 108/108 pass; package typecheck and Biome clean.