/** * `@nifrajs/web/dev-port` - what a dev server says when it cannot bind. * * Both pipelines need this and neither should own it: the Vite server binds through Node's `http` * (asynchronous `error` event), the Bun server binds through `Bun.serve` (synchronous throw). Two very * different failure mechanics, one thing the developer has to be told. * * That message is worth this much care because the visible symptom is not the real one. When the port is * taken, the EARLIER dev server is still answering on it, still serving the build it started with. Every * subsequent edit appears to do nothing. What reaches the developer is "my changes stopped reaching SSR", * which reads as broken HMR or a stale module graph and sends them into the module graph - not to the one * process that never started. Naming the cause here is the entire fix. * * This module deliberately imports nothing: it is shared by a Node-http path and a Bun path, and the * structural `ListenTarget` keeps it free of either runtime's types. */ /** The `EADDRINUSE` explanation. Exported so tests pin the exact text a user will read. */ export declare function portInUseMessage(port: number): string; /** True when an unknown thrown value carries the "address already in use" errno. */ export declare const isAddressInUse: (err: unknown) => boolean; /** Map a bind failure to the port-collision explanation, leaving every other failure as itself. */ export declare const explainBindFailure: (err: unknown, port: number) => Error; /** The bits of a Node server {@link listenOrExplain} touches - structural, so a test can fake it. */ export interface ListenTarget { listen(port: number, cb: () => void): void; once(event: "error", cb: (err: unknown) => void): void; removeListener(event: "error", cb: (err: unknown) => void): void; } /** * `listen`, but a bind failure becomes a readable nifra error instead of Node's raw internal throw. * * Without an `error` listener attached, Node throws from deep inside `node:events`, the new process dies * in the background, and nothing connects that death to the stale page in front of you. */ export declare function listenOrExplain(server: ListenTarget, port: number, hostname?: string): Promise; //# sourceMappingURL=dev-port.d.ts.map