fix(sandbox): serialize registry mutations and lock usage

This commit is contained in:
Peter Steinberger
2026-02-18 04:55:33 +01:00
parent 28bac46c92
commit 35016a380c
3 changed files with 18 additions and 10 deletions

View File

@@ -375,6 +375,7 @@ export async function acquireSessionWriteLock(params: {
timeoutMs?: number;
staleMs?: number;
maxHoldMs?: number;
allowReentrant?: boolean;
}): Promise<{
release: () => Promise<void>;
}> {
@@ -394,8 +395,9 @@ export async function acquireSessionWriteLock(params: {
const normalizedSessionFile = path.join(normalizedDir, path.basename(sessionFile));
const lockPath = `${normalizedSessionFile}.lock`;
const allowReentrant = params.allowReentrant ?? true;
const held = HELD_LOCKS.get(normalizedSessionFile);
if (held) {
if (allowReentrant && held) {
held.count += 1;
return {
release: async () => {