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
17
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.
+368
−40
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3e24dcd
perf(server): use native Windows APIs for preview discovery
gchen0002 1d332da
test(server): simplify Windows preview scanner fixtures
gchen0002 766b484
merge: sync main into windows native preview
maria-rcks c34f5bc
fix(server): fall back from native preview on 32-bit Windows
maria-rcks a39d804
fix(server): describe native Windows preview failures
gchen0002 f078d6c
fix(server): use tasklist when native process names fail
gchen0002 37fe2a5
fix(server): use tasklist for missing native process names
gchen0002 126de54
merge: sync main into windows native preview
maria-rcks 7b3e19d
Merge remote-tracking branch 'origin/main' into codex/windows-native-…
juliusmarminge a62cf5c
chore(server): tidy native Windows listener scan
juliusmarminge 3d62152
Merge remote-tracking branch 'origin/main' into codex/windows-native-…
juliusmarminge bc2e475
refactor(server): reuse WindowsTcpListener type for native scan rows
juliusmarminge 3b906e5
Merge remote-tracking branch 'origin/main' into codex/windows-native-…
juliusmarminge e187beb
Merge remote-tracking branch 'origin/main' into codex/windows-native-…
juliusmarminge 8a79dbe
refactor(server): share module-scoped ffi-rs require for preview disc…
juliusmarminge 790c0f0
Merge remote-tracking branch 'origin/main' into codex/windows-native-…
juliusmarminge 65bad8c
test(server): name native Windows listener test like its siblings
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.