refactor(core): dedupe shared config and runtime helpers

This commit is contained in:
Peter Steinberger
2026-02-16 14:52:03 +00:00
parent 544ffbcf7b
commit 04892ee230
68 changed files with 1966 additions and 2018 deletions

View File

@@ -92,3 +92,18 @@ export async function getDeterministicFreePortBlock(params?: {
throw new Error("failed to acquire a free port block");
}
export async function getFreePortBlockWithPermissionFallback(params: {
offsets: number[];
fallbackBase: number;
}): Promise<number> {
try {
return await getDeterministicFreePortBlock({ offsets: params.offsets });
} catch (err) {
const code = (err as NodeJS.ErrnoException | undefined)?.code;
if (code === "EPERM" || code === "EACCES") {
return params.fallbackBase + (process.pid % 10_000);
}
throw err;
}
}