Repository navigation
perf(server): use native Windows APIs for preview discovery #28239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gchen0002
wants to merge
12
commits into
pingdotgg:main
Choose a base branch
from
gchen0002:codex/windows-native-preview-20261031
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+370
−40
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4414660
perf(server): use native Windows APIs for preview discovery
gchen0002 af1c472
test(server): simplify Windows preview scanner fixtures
gchen0002 070782d
fix(server): fall back from native preview on 32-bit Windows
maria-rcks 295b939
fix(server): describe native Windows preview failures
gchen0002 d47f187
fix(server): use tasklist when native process names fail
gchen0002 cecd6f5
fix(server): use tasklist for missing native process names
gchen0002 efb296e
chore(server): tidy native Windows listener scan
juliusmarminge 304c8df
refactor(server): reuse WindowsTcpListener type for native scan rows
juliusmarminge 93b6d3e
refactor(server): share module-scoped ffi-rs require for preview disc…
juliusmarminge 22bfc82
test(server): name native Windows listener test like its siblings
juliusmarminge 9652bda
test(server): adapt native preview fixture to background policy
gchen0002 ad47946
Merge remote-tracking branch 'origin/main' into factory/pr-28239-adopt
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import * as NodeNet from "node:net"; | ||
|
|
||
| import { it } from "@effect/vitest"; | ||
| import * as HostProcess from "@t3tools/shared/HostProcess"; | ||
| import { fileBasename } from "@t3tools/shared/path"; | ||
| import * as Effect from "effect/Effect"; | ||
| import { expect } from "vite-plus/test"; | ||
|
|
||
| import * as WindowsTcpListeners from "./WindowsTcpListeners.ts"; | ||
|
|
||
| it.effect("reads native Windows IPv4/IPv6 wildcard and loopback listeners and process names", () => | ||
| Effect.gen(function* () { | ||
| if ((yield* HostProcess.Platform) !== "win32") return; | ||
| const ports: number[] = []; | ||
| for (const host of ["127.0.0.1", "0.0.0.0", "::1", "::"]) { | ||
| const server = yield* Effect.acquireRelease( | ||
| Effect.sync(() => NodeNet.createServer()), | ||
| (server) => | ||
| Effect.promise(() => new Promise<void>((resolve) => server.close(() => resolve()))), | ||
| ); | ||
| yield* Effect.promise( | ||
| () => | ||
| new Promise<void>((resolve, reject) => { | ||
| server.once("error", reject); | ||
| server.listen({ host, port: 0, ipv6Only: true }, resolve); | ||
| }), | ||
| ); | ||
| const address = server.address(); | ||
| if (address === null || typeof address === "string") throw new Error("Missing TCP address"); | ||
| ports.push(address.port); | ||
| } | ||
| const native = yield* WindowsTcpListeners.WindowsTcpListeners; | ||
| const rows = yield* native.scan; | ||
| for (const port of ports) expect(rows).toContainEqual({ port, pid: process.pid }); | ||
| expect(yield* native.processName(process.pid)).toBe( | ||
| fileBasename(process.execPath).replace(/\.exe$/i, ""), | ||
| ); | ||
| expect(yield* native.processName(0)).toBeNull(); | ||
| }).pipe(Effect.provide(WindowsTcpListeners.layer)), | ||
| ); | ||
|
|
||
| it.effect("rejects native TCP discovery on unsupported architectures", () => | ||
| Effect.gen(function* () { | ||
| const native = yield* WindowsTcpListeners.WindowsTcpListeners; | ||
| const error = yield* Effect.flip(native.scan); | ||
| expect(error.operation).toBe("load"); | ||
| expect(String(error.cause)).toContain("No native TCP discovery on ia32"); | ||
| }).pipe( | ||
| Effect.provide(WindowsTcpListeners.layer), | ||
| Effect.provideService(HostProcess.Architecture, "ia32"), | ||
| ), | ||
| ); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.