Skip to content

fix: allow concurrent non-local npx calls #8512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: latest
Choose a base branch
from

Conversation

jenseng
Copy link
Contributor

@jenseng jenseng commented Aug 15, 2025

If you kick off multiple npx processes at the same time for the same non-local package(s), they can potentially install atop each other in the same npx cache directory. This can cause one or both processes to fail silently, or with various errors (e.g. TAR_ENTRY_ERROR, ENOTEMPTY, EJSONPARSE, MODULE_NOT_FOUND), depending on when/where something gets clobbered. See this issue for more context and previous discussion.

This pull request introduces a lock around reading and reifying the tree in the npx cache directory, so that concurrent npx executions for the same non-local package(s) can succeed. The lock mechanism is based on mkdirs atomicity and implemented via proper-lockfile. proper-lockfile is battle tested and relatively lightweight (it just adds another version of signal-exit to the tree), but if desired I could update the PR to use a slightly simpler inline implementation.

References

Fixes #8224

@jenseng jenseng requested a review from a team as a code owner August 15, 2025 21:31
Copy link
Contributor

@wesleytodd wesleytodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] concurrent npx executions are not process-safe
2 participants