History

Stabilize auth session cookies per server mode (#1898)

Julius Marminge committed 7 months ago

Commit 4ae9de31 parent 5fa09fa11 files · +212 −22Browse files

Showing the changes to scripts/dev-runner.ts (1 of 11 files). Show all

Unified · Split

scripts/dev-runner.ts+21−2
@@ -9,11 +9,12 @@ import { Config, Data, Effect, Hash, Layer, Logger, Option, Path, Schema } from · 8 unmodified lines
99 import { Argument, Command, Flag } from "effect/unstable/cli";
1010 import { ChildProcess } from "effect/unstable/process";
1111
12−const BASE_SERVER_PORT = 3773;
12+const BASE_SERVER_PORT = 13773;
1313 const BASE_WEB_PORT = 5733;
1414 const MAX_HASH_OFFSET = 3000;
1515 const MAX_PORT = 65535;
1616 const DESKTOP_DEV_LOOPBACK_HOST = "127.0.0.1";
17+const DEV_PORT_PROBE_HOSTS = ["127.0.0.1", "0.0.0.0", "::1", "::"] as const;
1718
1819 export const DEFAULT_T3_HOME = Effect.map(Effect.service(Path.Path), (path) =>
1920 path.join(homedir(), ".t3"),
@@ -221,10 +222,28 @@ function portPairForOffset(offset: number): { · 201 unmodified lines
221222 };
222223 }
223224
225+export function checkPortAvailabilityOnHosts<R>(
226+ port: number,
227+ hosts: ReadonlyArray<string>,
228+ canListenOnHost: (port: number, host: string) => Effect.Effect<boolean, never, R>,
229+): Effect.Effect<boolean, never, R> {
230+ return Effect.gen(function* () {
231+ for (const host of hosts) {
232+ if (!(yield* canListenOnHost(port, host))) {
233+ return false;
234+ }
235+ }
236+
237+ return true;
238+ });
239+}
240+
224241 const defaultCheckPortAvailability: PortAvailabilityCheck<NetService> = (port) =>
225242 Effect.gen(function* () {
226243 const net = yield* NetService;
227− return yield* net.isPortAvailableOnLoopback(port);
244+ return yield* checkPortAvailabilityOnHosts(port, DEV_PORT_PROBE_HOSTS, (candidatePort, host) =>
245+ net.canListenOnHost(candidatePort, host),
246+ );
228247 });
229248
230249 interface FindFirstAvailableOffsetInput<R = NetService> {