fix: prevent EBUSY caused by parallel dlx (#8604)
This commit is contained in:
2 files changed
+17
-1
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@pnpm/plugin-commands-script-runners": patch
|
||||||
|
"pnpm": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Prevent `EBUSY` errors caused by calling `symlinkDir` in parallel `dlx` processes.
|
||||||
@@ -91,7 +91,17 @@ export async function handler (
|
|||||||
saveOptional: false,
|
saveOptional: false,
|
||||||
savePeer: false,
|
savePeer: false,
|
||||||
}, pkgs)
|
}, pkgs)
|
||||||
await symlinkDir(cachedDir, cacheLink, { overwrite: true })
|
try {
|
||||||
|
await symlinkDir(cachedDir, cacheLink, { overwrite: true })
|
||||||
|
} catch (error) {
|
||||||
|
// EBUSY means that there is another dlx process running in parallel that has acquired the cache link first.
|
||||||
|
// The link created by the other process is just as up-to-date as the link the current process was attempting
|
||||||
|
// to create. Therefore, instead of re-attempting to create the current link again, it is just as good to let
|
||||||
|
// the other link stay. The current process should yield.
|
||||||
|
if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'EBUSY') {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const modulesDir = path.join(cachedDir, 'node_modules')
|
const modulesDir = path.join(cachedDir, 'node_modules')
|
||||||
const binsDir = path.join(modulesDir, '.bin')
|
const binsDir = path.join(modulesDir, '.bin')
|
||||||
|
|||||||
Reference in new issue
Block a user