fix: harden memory indexing and embedded session locks

This commit is contained in:
Peter Steinberger
2026-01-18 04:29:42 +00:00
parent b7575a889e
commit cf8b3ed988
2 changed files with 66 additions and 69 deletions

View File

@@ -1,4 +1,5 @@
import fs from "node:fs/promises";
import path from "node:path";
type LockFilePayload = {
pid: number;
@@ -46,6 +47,7 @@ export async function acquireSessionWriteLock(params: {
const staleMs = params.staleMs ?? 30 * 60 * 1000;
const sessionFile = params.sessionFile;
const lockPath = `${sessionFile}.lock`;
await fs.mkdir(path.dirname(lockPath), { recursive: true });
const held = HELD_LOCKS.get(sessionFile);
if (held) {