Skip to content

Commit 2fa6f67

Browse files
authored
test: fix race condition in sandbox pack lock (#8183)
1 parent b815a11 commit 2fa6f67

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

integration-tests/helpers/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,16 +479,21 @@ async function packTarballWithLock (tarballPath, env) {
479479

480480
while (!existsSync(tarballPath)) {
481481
await new Promise(resolve => setTimeout(resolve, 100))
482+
if (!existsSync(lockFile) && !existsSync(tarballPath)) {
483+
// Lock holder failed without creating the tarball, retry from scratch
484+
log('Lock released without tarball, retrying:', tarballPath)
485+
return packTarballWithLock(tarballPath, env)
486+
}
482487
}
483488

484489
log('Tarball ready:', tarballPath)
485490
} else {
486491
throw err
487492
}
488493
} finally {
489-
// Strictly no need to clean up the lock - it's in a temp directory
490494
if (lockFd) {
491-
lockFd.close().catch(() => {})
495+
await lockFd.close().catch(() => {})
496+
await fs.unlink(lockFile).catch(() => {})
492497
}
493498
}
494499
}

0 commit comments

Comments
 (0)