perf(test): reduce memory and port probe overhead

This commit is contained in:
Peter Steinberger
2026-02-13 23:22:30 +00:00
parent 1aa746f042
commit dc507f3dec
3 changed files with 27 additions and 112 deletions

View File

@@ -42,8 +42,7 @@ export async function ensurePortAvailable(port: number): Promise<void> {
});
} catch (err) {
if (isErrno(err) && err.code === "EADDRINUSE") {
const details = await describePortOwner(port);
throw new PortInUseError(port, details);
throw new PortInUseError(port);
}
throw err;
}
@@ -57,7 +56,10 @@ export async function handlePortError(
): Promise<never> {
// Uniform messaging for EADDRINUSE with optional owner details.
if (err instanceof PortInUseError || (isErrno(err) && err.code === "EADDRINUSE")) {
const details = err instanceof PortInUseError ? err.details : await describePortOwner(port);
const details =
err instanceof PortInUseError
? (err.details ?? (await describePortOwner(port)))
: await describePortOwner(port);
runtime.error(danger(`${context} failed: port ${port} is already in use.`));
if (details) {
runtime.error(info("Port listener details:"));