@devries-cameron20 / t3code Mirror · read-only / commits / 318201caa5
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 16:45 UTC

fix(server): probe only owned preview listeners (#16687)

Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>

maria committed Oct 9, 2026 at 23:31 UTC 318201caa520525517ef2bee8f4bbeedb2fec1d7
2 files changed +110 -132
apps/server/src/preview/PortScanner.test.ts
+76 -87
@@ -7,7 +7,6 @@ import {
7 type DiscoveredLocalServer,
8 } from "@t3tools/contracts";
9 import * as HostProcess from "@t3tools/shared/HostProcess";
10 -import * as Net from "@t3tools/shared/Net";
10 import * as Cause from "effect/Cause";
11 import * as Clock from "effect/Clock";
12 import * as Duration from "effect/Duration";
@@ -44,17 +43,7 @@ const layerTestProcessRunner = Layer.succeed(ProcessRunner.ProcessRunner, {
43 run: processProbeFailure,
44 });
45
47 -let integrationListeningPort: number | null = null;
48 -
49 -const layerTestIntegrationNet = Layer.succeed(Net.NetService, {
50 - canListenOnHost: () => Effect.succeed(true),
51 - isPortAvailableOnLoopback: (port) => Effect.sync(() => port !== integrationListeningPort),
52 - hasListenerOnHost: (port) => Effect.sync(() => port === integrationListeningPort),
53 - reserveLoopbackPort: () => Effect.succeed(40_000),
54 - findAvailablePort: (preferred) => Effect.succeed(preferred),
55 -});
56 -
57 -/** A host without `/proc`, so a missing `lsof` falls back to common ports. */
46 +/** A host without `/proc`, so a missing `lsof` leaves only configured URLs. */
47 const layerNoProc = FileSystem.layerNoop({});
48
49 const layerProbeFailure = (
@@ -67,13 +56,6 @@ const layerProbeFailure = (
56 Layer.mergeAll(
57 fileSystem,
58 Layer.succeed(ProcessRunner.ProcessRunner, { run }),
70 - Layer.succeed(Net.NetService, {
71 - canListenOnHost: () => Effect.succeed(true),
72 - isPortAvailableOnLoopback: () => Effect.succeed(true),
73 - hasListenerOnHost: () => Effect.succeed(false),
74 - reserveLoopbackPort: () => Effect.succeed(40_000),
75 - findAvailablePort: (preferred) => Effect.succeed(preferred),
76 - }),
59 Layer.succeed(HostProcess.Platform, "linux"),
60 FetchHttpClient.layer.pipe(Layer.provide(Layer.succeed(FetchHttpClient.Fetch, fetch))),
61 ),
@@ -85,7 +67,6 @@ const layerTestPortDiscovery = PortScanner.layer.pipe(
67 Layer.mergeAll(
68 layerNoProc,
69 layerTestProcessRunner,
88 - layerTestIntegrationNet,
70 Layer.succeed(HostProcess.Platform, "win32"),
71 FetchHttpClient.layer,
72 ),
@@ -94,9 +75,20 @@ const layerTestPortDiscovery = PortScanner.layer.pipe(
75
76 const LSOF_TEST_PORT = 43_123;
77
78 +/** The scanner with `processIds` registered to a T3 terminal, so their listeners get probes. */
79 +const ownedScanner = (processIds: ReadonlyArray<number> = [1234]) =>
80 + Effect.tap(PortScanner.PortDiscovery, (scanner) =>
81 + scanner.registerTerminalProcesses({
82 + threadId: "scanner-thread",
83 + terminalId: "scanner-terminal",
84 + processIds,
85 + }),
86 + );
87 +
88 const layerLsofScanner = (input: {
89 readonly pid: () => number;
90 readonly fetch: typeof globalThis.fetch;
91 + readonly stdout?: () => string;
92 }) =>
93 PortScanner.layer.pipe(
94 Layer.provide(
@@ -105,7 +97,7 @@ const layerLsofScanner = (input: {
97 Layer.succeed(ProcessRunner.ProcessRunner, {
98 run: () =>
99 Effect.succeed({
108 - stdout: `p${input.pid()}\ncnode\nn*:${LSOF_TEST_PORT}\n`,
100 + stdout: input.stdout?.() ?? `p${input.pid()}\ncnode\nn*:${LSOF_TEST_PORT}\n`,
101 stderr: "",
102 code: null,
103 timedOut: false,
@@ -115,13 +107,6 @@ const layerLsofScanner = (input: {
107 stderrInvalidUtf8: false,
108 }),
109 }),
118 - Layer.succeed(Net.NetService, {
119 - canListenOnHost: () => Effect.succeed(true),
120 - isPortAvailableOnLoopback: () => Effect.succeed(true),
121 - hasListenerOnHost: () => Effect.succeed(false),
122 - reserveLoopbackPort: () => Effect.succeed(40_000),
123 - findAvailablePort: (preferred) => Effect.succeed(preferred),
124 - }),
110 Layer.succeed(HostProcess.Platform, "linux"),
111 FetchHttpClient.layer.pipe(
112 Layer.provide(Layer.succeed(FetchHttpClient.Fetch, input.fetch)),
@@ -153,73 +138,45 @@ const closeServer = (server: NodeNet.Server): Effect.Effect<void> =>
138 });
139
140 const openCommonDevServer = Effect.fn("PortScannerTest.openCommonDevServer")(function* (
156 - ports: ReadonlyArray<number>,
141 onConnection: (socket: NodeNet.Socket) => void,
142 ) {
159 - for (const port of ports) {
160 - const server = yield* openServer(port, onConnection);
161 - if (server !== null) return { port, server };
143 + const server = yield* openServer(0, onConnection);
144 + const address = server?.address();
145 + if (!server || !address || typeof address === "string") {
146 + return yield* Effect.die(new Error("Could not open the preview scanner test listener"));
147 }
163 - return yield* Effect.die(
164 - new Error("No common development port was available for the preview scanner test"),
165 - );
148 + return { port: address.port, server };
149 });
150
151 const commonDevServer = Effect.acquireRelease(
169 - openCommonDevServer(PortScanner.COMMON_DEV_PORTS, (socket) => {
152 + openCommonDevServer((socket) => {
153 socket.once("data", () => {
154 socket.end("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: 5\r\n\r\nhello");
155 });
173 - }).pipe(
174 - Effect.tap(({ port }) =>
175 - Effect.sync(() => {
176 - integrationListeningPort = port;
177 - }),
178 - ),
179 - ),
180 - ({ server }) =>
181 - closeServer(server).pipe(
182 - Effect.ensuring(
183 - Effect.sync(() => {
184 - integrationListeningPort = null;
185 - }),
186 - ),
187 - ),
156 + }),
157 + ({ server }) => closeServer(server),
158 );
159
160 const commonNonHttpServer = Effect.acquireRelease(
191 - openCommonDevServer(PortScanner.COMMON_DEV_PORTS.toReversed(), (socket) => {
161 + openCommonDevServer((socket) => {
162 socket.on("error", () => undefined);
163 socket.once("data", () => socket.end("MYSQL\r\n\r\n"));
194 - }).pipe(
195 - Effect.tap(({ port }) =>
196 - Effect.sync(() => {
197 - integrationListeningPort = port;
198 - }),
199 - ),
200 - ),
201 - ({ server }) =>
202 - closeServer(server).pipe(
203 - Effect.ensuring(
204 - Effect.sync(() => {
205 - integrationListeningPort = null;
206 - }),
207 - ),
208 - ),
164 + }),
165 + ({ server }) => closeServer(server),
166 );
167
168 /**
169 * Integration tests against a real TCP listener. We provide the Windows host
213 - * platform so the tests exercise the TCP-probe fallback without depending on
214 - * `lsof` being installed.
170 + * platform with a failing listener probe so the tests exercise configured URLs
171 + * without depending on `lsof` being installed.
172 */
216 -effectIt.layer(layerTestPortDiscovery)("PortDiscovery integration (TCP probe fallback)", (it) => {
173 +effectIt.layer(layerTestPortDiscovery)("PortDiscovery integration (configured URLs)", (it) => {
174 it.effect(
218 - "scan() returns an HTTP server we just opened on a curated dev port",
175 + "scan() returns a configured HTTP server we just opened",
176 Effect.fn("PortScannerTest.scanFindsCommonDevServer")(function* () {
177 const { port } = yield* commonDevServer;
178 const scanner = yield* PortScanner.PortDiscovery;
222 - const result = yield* scanner.scan();
179 + const result = yield* scanner.scan([`http://localhost:${port}`]);
180 const found = result.find((server) => server.port === port);
181 expect(found).toBeDefined();
182 expect(found?.host).toBe("localhost");
@@ -231,7 +188,7 @@ effectIt.layer(layerTestPortDiscovery)("PortDiscovery integration (TCP probe fal
188 Effect.fn("PortScannerTest.scanExcludesNonHttpServer")(function* () {
189 const { port } = yield* commonNonHttpServer;
190 const scanner = yield* PortScanner.PortDiscovery;
234 - const result = yield* scanner.scan();
191 + const result = yield* scanner.scan([`http://localhost:${port}`]);
192 expect(result.some((server) => server.port === port)).toBe(false);
193 }),
194 );
@@ -242,10 +199,12 @@ effectIt.layer(layerTestPortDiscovery)("PortDiscovery integration (TCP probe fal
199 const { port } = yield* commonDevServer;
200 const received: number[] = [];
201 const scanner = yield* PortScanner.PortDiscovery;
245 - yield* scanner.subscribe({ configuredUrls: [], initialSnapshot: [] }, (servers) =>
246 - Effect.sync(() => {
247 - for (const server of servers) received.push(server.port);
248 - }),
202 + yield* scanner.subscribe(
203 + { configuredUrls: [`http://localhost:${port}`], initialSnapshot: [] },
204 + (servers) =>
205 + Effect.sync(() => {
206 + for (const server of servers) received.push(server.port);
207 + }),
208 );
209 yield* scanner.retain;
210 expect(received).toContain(port);
@@ -265,7 +224,7 @@ effectIt.effect("revalidates a successful HTML probe after its cache entry expir
224 const layer = layerLsofScanner({ pid: () => 1234, fetch: fetchFn });
225
226 return Effect.gen(function* () {
268 - const scanner = yield* PortScanner.PortDiscovery;
227 + const scanner = yield* ownedScanner();
228 expect(yield* scanner.scan()).toHaveLength(1);
229 expect(yield* scanner.scan()).toHaveLength(1);
230 expect(requests).toEqual([`http://localhost:${LSOF_TEST_PORT}/`]);
@@ -499,7 +458,7 @@ effectIt.effect("shares a configured root probe with discovered-root classificat
458 const layer = layerLsofScanner({ pid: () => 1234, fetch: fetchFn });
459
460 return Effect.gen(function* () {
502 - const scanner = yield* PortScanner.PortDiscovery;
461 + const scanner = yield* ownedScanner();
462 expect(yield* scanner.scan([rootUrl])).toHaveLength(1);
463 expect(requests).toEqual([rootUrl]);
464
@@ -528,7 +487,7 @@ effectIt.effect("starts fresh cache entries after the probing batch completes",
487 const layer = layerLsofScanner({ pid: () => 1234, fetch: fetchFn });
488
489 yield* Effect.gen(function* () {
531 - const scanner = yield* PortScanner.PortDiscovery;
490 + const scanner = yield* ownedScanner();
491 expect(yield* scanner.scan()).toHaveLength(1);
492 expect(yield* scanner.scan()).toHaveLength(1);
493 expect(requests).toHaveLength(1);
@@ -548,7 +507,7 @@ effectIt.effect("caches a failed web probe until its bounded cache entry expires
507 const layer = layerLsofScanner({ pid: () => 1234, fetch: fetchFn });
508
509 return Effect.gen(function* () {
551 - const scanner = yield* PortScanner.PortDiscovery;
510 + const scanner = yield* ownedScanner();
511 expect(yield* scanner.scan()).toHaveLength(0);
512 expect(yield* scanner.scan()).toHaveLength(0);
513 expect(requests).toHaveLength(2);
@@ -573,7 +532,7 @@ effectIt.effect("falls back to HTTPS and does not follow redirects while probing
532 const layer = layerLsofScanner({ pid: () => 1234, fetch: fetchFn });
533
534 return Effect.gen(function* () {
576 - const scanner = yield* PortScanner.PortDiscovery;
535 + const scanner = yield* ownedScanner();
536 const servers = yield* scanner.scan();
537 expect(servers).toHaveLength(1);
538 expect(servers[0]?.url).toBe(`https://localhost:${LSOF_TEST_PORT}`);
@@ -581,6 +540,37 @@ effectIt.effect("falls back to HTTPS and does not follow redirects while probing
540 }).pipe(Effect.provide(layer));
541 });
542
543 +effectIt.effect("probes a port only while T3 terminals own every listener on it", () => {
544 + const owned = `p1234\ncnode\nn[::1]:${LSOF_TEST_PORT}\n`;
545 + const unowned = `p5678\ncrpc\nn127.0.0.1:${LSOF_TEST_PORT}\n`;
546 + let stdout = unowned;
547 + const requests: string[] = [];
548 + const fetchFn = ((input: Parameters<typeof globalThis.fetch>[0]) => {
549 + requests.push(String(input));
550 + return Promise.resolve(new Response("app", { headers: { "content-type": "text/html" } }));
551 + }) as typeof globalThis.fetch;
552 + const layer = layerLsofScanner({ pid: () => 1234, fetch: fetchFn, stdout: () => stdout });
553 +
554 + return Effect.gen(function* () {
555 + const scanner = yield* ownedScanner();
556 + expect(yield* scanner.scan()).toHaveLength(0);
557 + stdout = `${owned}${unowned}`;
558 + expect(yield* scanner.scan()).toHaveLength(0);
559 + expect(requests).toEqual([]);
560 +
561 + stdout = owned;
562 + expect(yield* scanner.scan()).toHaveLength(1);
563 + expect(requests).toEqual([`http://localhost:${LSOF_TEST_PORT}/`]);
564 +
565 + yield* scanner.unregisterTerminal({
566 + threadId: "scanner-thread",
567 + terminalId: "scanner-terminal",
568 + });
569 + expect(yield* scanner.scan()).toHaveLength(0);
570 + expect(requests).toHaveLength(1);
571 + }).pipe(Effect.provide(layer));
572 +});
573 +
574 effectIt.effect(
575 "excludes HTTP errors, non-navigation responses, and successful non-documents",
576 () => {
@@ -592,7 +582,7 @@ effectIt.effect(
582 const layer = layerLsofScanner({ pid: () => pid, fetch: fetchFn });
583
584 return Effect.gen(function* () {
595 - const scanner = yield* PortScanner.PortDiscovery;
585 + const scanner = yield* ownedScanner([1, 2, 3, 4, 5, 6, 7]);
586 expect(yield* scanner.scan()).toHaveLength(0);
587
588 pid += 1;
@@ -650,7 +640,7 @@ effectIt.effect("aborts HTTP and HTTPS probes when they time out", () => {
640 const layer = layerLsofScanner({ pid: () => 1234, fetch: fetchFn });
641
642 return Effect.gen(function* () {
653 - const scanner = yield* PortScanner.PortDiscovery;
643 + const scanner = yield* ownedScanner();
644 const scanFiber = yield* Effect.forkChild(scanner.scan());
645 yield* TestClock.adjust(Duration.seconds(2));
646 expect(yield* Fiber.join(scanFiber)).toHaveLength(0);
@@ -739,11 +729,10 @@ effectIt.effect(
729 );
730
731 return Effect.gen(function* () {
742 - const scanner = yield* PortScanner.PortDiscovery;
732 + const scanner = yield* ownedScanner([4242]);
733 const first = yield* scanner.scan();
734 + // Ports 22 and 3001 have no known owner, so they never receive probes.
735 expect(first.map(({ port, pid, processName }) => ({ port, pid, processName }))).toEqual([
745 - { port: 22, pid: null, processName: null },
746 - { port: 3001, pid: null, processName: null },
736 { port: 8765, pid: 4242, processName: "python3" },
737 ]);
738 yield* scanner.scan();
apps/server/src/preview/PortScanner.ts
+34 -45
@@ -8,8 +8,8 @@
8 * Linux without lsof: reads listening sockets from `/proc/net/tcp{,6}` and
9 * finds their processes through `/proc/<pid>/fd`.
10 *
11 - * Windows listener failures, or neither source: checks a curated list of
12 - * common dev ports through the shared Net service.
11 + * Only listeners owned by T3 terminal processes and explicitly configured
12 + * URLs receive probes. Without listener ownership, only configured URLs do.
13 *
14 * Listening ports are published only after a bounded HTTP(S) probe finds a
15 * successful HTML document or a redirect to one.
@@ -26,7 +26,6 @@ import {
26 type DiscoveredLocalServer,
27 } from "@t3tools/contracts";
28 import * as HostProcess from "@t3tools/shared/HostProcess";
29 -import * as Net from "@t3tools/shared/Net";
29 import { isLoopbackHost, LSOF_LOCAL_HOST_TOKENS } from "@t3tools/shared/preview";
30 import * as Cause from "effect/Cause";
31 import * as Clock from "effect/Clock";
@@ -71,10 +70,6 @@ export class PortDiscovery extends Context.Service<
70 }
71 >()("t3/preview/PortScanner/PortDiscovery") {}
72
74 -export const COMMON_DEV_PORTS: ReadonlyArray<number> = Object.freeze([
75 - 3000, 3001, 3333, 4173, 4200, 4321, 5000, 5173, 5174, 5175, 5500, 8000, 8080, 8081, 8888, 9000,
76 -]);
77 -
73 const POLL_INTERVAL = Duration.seconds(3);
74 const LSOF_TIMEOUT_MS = 5_000;
75 /** File descriptors one `/proc` walk may read before it stops looking for socket owners. */
@@ -218,14 +213,20 @@ const parseLsofOutput = (
213 if (portMatch == null) continue;
214 const url = `http://localhost:${portMatch}`;
215 const key = `localhost:${portMatch}`;
221 - if (seen.has(key)) continue;
216 + const terminal = pid === null ? null : (terminalByProcessId.get(pid) ?? null);
217 + const existing = seen.get(key);
218 + // A port receives probes only when T3 terminals own all of its listeners.
219 + if (existing) {
220 + if (terminal === null) seen.set(key, { ...existing, terminal: null });
221 + continue;
222 + }
223 seen.set(key, {
224 host: "localhost",
225 port: portMatch,
226 url,
227 processName,
228 pid,
228 - terminal: pid === null ? null : (terminalByProcessId.get(pid) ?? null),
229 + terminal,
230 });
231 }
232 }
@@ -261,14 +262,20 @@ const parseWindowsListenerOutput = (
262 const pid = Number(pidRaw);
263 if (!Number.isInteger(port) || port <= 0 || port >= 65536) continue;
264 const normalizedPid = Number.isInteger(pid) && pid > 0 ? pid : null;
264 - if (seen.has(port)) continue;
265 + const terminal =
266 + normalizedPid === null ? null : (terminalByProcessId.get(normalizedPid) ?? null);
267 + const existing = seen.get(port);
268 + if (existing) {
269 + if (terminal === null) seen.set(port, { ...existing, terminal: null });
270 + continue;
271 + }
272 seen.set(port, {
273 host: "localhost",
274 port,
275 url: `http://localhost:${port}`,
276 processName: processNameRaw?.trim() || null,
277 pid: normalizedPid,
271 - terminal: normalizedPid === null ? null : (terminalByProcessId.get(normalizedPid) ?? null),
278 + terminal,
279 });
280 }
281 return [...seen.values()].toSorted((left, right) => left.port - right.port);
@@ -339,7 +346,6 @@ const isCommandNotFound = (error: ProcessRunner.ProcessSpawnError): boolean =>
346
347 /** @public Service construction is part of the canonical Effect module API. */
348 export const make = Effect.gen(function* PortDiscoveryMake() {
342 - const net = yield* Net.NetService;
349 const processRunner = yield* ProcessRunner.ProcessRunner;
350 const fileSystem = yield* FileSystem.FileSystem;
351 const hostPlatform = yield* HostProcess.Platform;
@@ -398,7 +404,7 @@ export const make = Effect.gen(function* PortDiscoveryMake() {
404
405 /**
406 * Linux listeners from `/proc/net/tcp{,6}`, for hosts without `lsof`. Null
401 - * when neither file is readable, so discovery falls back to common ports.
407 + * when neither file is readable, so only configured URLs are probed.
408 */
409 const scanProcListeners = Effect.fn("PortDiscovery.scanProcListeners")(function* (
410 terminalByProcessId: ReadonlyMap<number, TerminalProcessOwner>,
@@ -433,44 +439,25 @@ export const make = Effect.gen(function* PortDiscoveryMake() {
439 const seen = new Map<number, DiscoveredLocalServer>();
440 for (const { port, inode } of listeners) {
441 const owner = owners.get(inode) ?? null;
442 + const terminal = owner === null ? null : (terminalByProcessId.get(owner.pid) ?? null);
443 const existing = seen.get(port);
437 - if (existing && (existing.pid !== null || owner === null)) continue;
444 + if (existing && (existing.pid !== null || owner === null)) {
445 + if (terminal === null) seen.set(port, { ...existing, terminal: null });
446 + continue;
447 + }
448 seen.set(port, {
449 host: "localhost",
450 port,
451 url: `http://localhost:${port}`,
452 processName: owner?.processName ?? null,
453 pid: owner?.pid ?? null,
444 - terminal: owner === null ? null : (terminalByProcessId.get(owner.pid) ?? null),
454 + // A replaced listener had no known owner, so the port stays unowned.
455 + terminal: existing ? null : terminal,
456 });
457 }
458 return [...seen.values()].toSorted((left, right) => left.port - right.port);
459 });
460
450 - const probeCommonPorts = Effect.fn("PortDiscovery.probeCommonPorts")(function* () {
451 - const results = yield* Effect.forEach(
452 - COMMON_DEV_PORTS,
453 - (port) =>
454 - net.isPortAvailableOnLoopback(port).pipe(
455 - Effect.map((available) => ({
456 - port,
457 - listening: !available,
458 - })),
459 - ),
460 - { concurrency: "unbounded" },
461 - );
462 - return results
463 - .filter((result) => result.listening)
464 - .map<DiscoveredLocalServer>((result) => ({
465 - host: "localhost",
466 - port: result.port,
467 - url: `http://localhost:${result.port}`,
468 - processName: null,
469 - pid: null,
470 - terminal: null,
471 - }));
472 - });
473 -
461 const probeWebUrl = Effect.fn("PortDiscovery.probeWebUrl")((url: string) =>
462 httpClient.get(url).pipe(
463 Effect.map((response) => {
@@ -524,6 +511,9 @@ export const make = Effect.gen(function* PortDiscoveryMake() {
511 }
512
513 for (const server of servers) {
514 + // A listener alone does not identify its protocol. Sending HTTP or TLS to
515 + // another app's binary RPC listener can crash it before classification.
516 + if (server.terminal === null) continue;
517 groups.push({
518 server,
519 urls: [`http://${server.host}:${server.port}`, `https://${server.host}:${server.port}`],
@@ -616,7 +606,7 @@ export const make = Effect.gen(function* PortDiscoveryMake() {
606
607 const recoverProcessProbeFailure =
608 (probe: "lsof" | "windows-listeners") => (error: ProcessRunner.ProcessRunError) =>
619 - Effect.logDebug("preview port process probe failed; falling back to common-port probes", {
609 + Effect.logDebug("preview port process probe failed; probing configured URLs only", {
610 cause: error,
611 probe,
612 platform: hostPlatform,
@@ -642,7 +632,6 @@ export const make = Effect.gen(function* PortDiscoveryMake() {
632 args: ["-NoProfile", "-NonInteractive", "-Command", command],
633 timeout: Duration.millis(WINDOWS_LISTENER_TIMEOUT_MS),
634 maxOutputBytes: 1024 * 1024,
645 - outputMode: "truncate",
635 })
636 .pipe(
637 Effect.map((result) => parseWindowsListenerOutput(result.stdout, terminalByProcessId)),
@@ -655,20 +644,20 @@ export const make = Effect.gen(function* PortDiscoveryMake() {
644 }),
645 );
646 if (listeners !== null) return yield* probeWebServers(listeners, configuredUrls);
658 - return yield* probeWebServers(yield* probeCommonPorts(), configuredUrls);
647 + return yield* probeWebServers([], configuredUrls);
648 }
649 const recoverLsofProbeFailure = recoverProcessProbeFailure("lsof");
650 if (yield* Ref.get(lsofMissingRef)) {
651 const fromProc = yield* scanProcListeners(terminalByProcessId);
663 - return yield* probeWebServers(fromProc ?? (yield* probeCommonPorts()), configuredUrls);
652 + return yield* probeWebServers(fromProc ?? [], configuredUrls);
653 }
654 const lsofResult = yield* processRunner
655 .run({
656 command: "lsof",
657 args: ["-iTCP", "-sTCP:LISTEN", "-P", "-n", "-F", "pcn"],
658 timeout: Duration.millis(LSOF_TIMEOUT_MS),
659 + // Partial output could hide another app's listener on an owned port.
660 maxOutputBytes: 1024 * 1024,
671 - outputMode: "truncate",
661 })
662 .pipe(
663 Effect.map((result) => parseLsofOutput(result.stdout, terminalByProcessId)),
@@ -686,7 +675,7 @@ export const make = Effect.gen(function* PortDiscoveryMake() {
675 );
676 if (lsofResult !== null) return yield* probeWebServers(lsofResult, configuredUrls);
677 const fromProc = yield* scanProcListeners(terminalByProcessId);
689 - return yield* probeWebServers(fromProc ?? (yield* probeCommonPorts()), configuredUrls);
678 + return yield* probeWebServers(fromProc ?? [], configuredUrls);
679 });
680
681 const scanSnapshot = Effect.fn("PortDiscovery.scanSnapshot")(