serve: avoid fake socket listener port

This commit is contained in:
Dax Raad 2026-05-16 01:00:02 -04:00
commit 91d148d95f

View file

@ -119,7 +119,7 @@ const listenEffect: (opts: ListenOptions) => Effect.Effect<EffectListener, unkno
function* (opts: ListenOptions) { function* (opts: ListenOptions) {
const state = yield* startWithPortFallback(opts) const state = yield* startWithPortFallback(opts)
if (opts.type === "socket") { if (opts.type === "socket") {
const listenerUrl = makeURL("localhost", 0) const listenerUrl = makeURL("localhost")
url = listenerUrl url = listenerUrl
return { return {
@ -194,10 +194,10 @@ function tcpAddress(state: ListenerState) {
}) })
} }
function makeURL(hostname: string, port: number) { function makeURL(hostname: string, port?: number) {
const result = new URL("http://localhost") const result = new URL("http://localhost")
result.hostname = hostname result.hostname = hostname
result.port = String(port) if (port !== undefined) result.port = String(port)
return result return result
} }