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
9import { Argument, Command, Flag } from "effect/unstable/cli";9import { Argument, Command, Flag } from "effect/unstable/cli";
10import { ChildProcess } from "effect/unstable/process";10import { ChildProcess } from "effect/unstable/process";
11 11
12const BASE_SERVER_PORT = 3773;12const BASE_SERVER_PORT = 13773;
13const BASE_WEB_PORT = 5733;13const BASE_WEB_PORT = 5733;
14const MAX_HASH_OFFSET = 3000;14const MAX_HASH_OFFSET = 3000;
15const MAX_PORT = 65535;15const MAX_PORT = 65535;
16const DESKTOP_DEV_LOOPBACK_HOST = "127.0.0.1";16const DESKTOP_DEV_LOOPBACK_HOST = "127.0.0.1";
17const DEV_PORT_PROBE_HOSTS = ["127.0.0.1", "0.0.0.0", "::1", "::"] as const;
17 18
18export const DEFAULT_T3_HOME = Effect.map(Effect.service(Path.Path), (path) =>19export const DEFAULT_T3_HOME = Effect.map(Effect.service(Path.Path), (path) =>
19 path.join(homedir(), ".t3"),20 path.join(homedir(), ".t3"),
@@ -221,10 +222,28 @@ function portPairForOffset(offset: number): { · 201 unmodified lines
221 };222 };
222}223}
223 224
225export 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
224const defaultCheckPortAvailability: PortAvailabilityCheck<NetService> = (port) =>241const defaultCheckPortAvailability: PortAvailabilityCheck<NetService> = (port) =>
225 Effect.gen(function* () {242 Effect.gen(function* () {
226 const net = yield* NetService;243 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 );
228 });247 });
229 248
230interface FindFirstAvailableOffsetInput<R = NetService> {249interface FindFirstAvailableOffsetInput<R = NetService> {