mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-18 13:51:38 -04:00
fix(dlx): race condition (#8712)
This commit is contained in:
6
.changeset/fifty-beers-hear.md
Normal file
6
.changeset/fifty-beers-hear.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@pnpm/plugin-commands-script-runners": patch
|
||||||
|
"pnpm": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix race condition of symlink creations caused by multiple parallel `dlx` processes.
|
||||||
@@ -95,10 +95,11 @@ export async function handler (
|
|||||||
await symlinkDir(cachedDir, cacheLink, { overwrite: true })
|
await symlinkDir(cachedDir, cacheLink, { overwrite: true })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// EBUSY means that there is another dlx process running in parallel that has acquired the cache link first.
|
// EBUSY means that there is another dlx process running in parallel that has acquired the cache link first.
|
||||||
|
// Similarly, EEXIST means that another dlx process has created the cache link before this process.
|
||||||
// The link created by the other process is just as up-to-date as the link the current process was attempting
|
// 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
|
// 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.
|
// the other link stay. The current process should yield.
|
||||||
if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'EBUSY') {
|
if (!util.types.isNativeError(error) || !('code' in error) || (error.code !== 'EBUSY' && error.code !== 'EEXIST')) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user