test: isolate gateway lock per run

This commit is contained in:
Peter Steinberger
2025-12-10 00:58:59 +00:00
parent cf8b00890f
commit 3907e9eedd
3 changed files with 37 additions and 15 deletions

View File

@@ -4,7 +4,9 @@ import path from "node:path";
import { flockSync } from "fs-ext";
const DEFAULT_LOCK_PATH = path.join(os.tmpdir(), "clawdis-gateway.lock");
const defaultLockPath = () =>
process.env.CLAWDIS_GATEWAY_LOCK_PATH ??
path.join(os.tmpdir(), "clawdis-gateway.lock");
export class GatewayLockError extends Error {}
@@ -20,7 +22,7 @@ const SIGNALS: NodeJS.Signals[] = ["SIGINT", "SIGTERM", "SIGHUP"];
* correctness relies solely on the kernel lock.
*/
export async function acquireGatewayLock(
lockPath = DEFAULT_LOCK_PATH,
lockPath = defaultLockPath(),
): Promise<ReleaseFn> {
fs.mkdirSync(path.dirname(lockPath), { recursive: true });