Skip to content

Fix pnpm prerelease selection (#774) and preinstall shim deadlock#798

Closed
AMDphreak wants to merge 1 commit intonodejs:mainfrom
AMDphreak:fix/prerelease-selection-and-deadlock
Closed

Fix pnpm prerelease selection (#774) and preinstall shim deadlock#798
AMDphreak wants to merge 1 commit intonodejs:mainfrom
AMDphreak:fix/prerelease-selection-and-deadlock

Conversation

@AMDphreak
Copy link

This PR addresses two related issues encountered on Windows with Corepack...\n\n### Issue 1: Deadlock during corepack use with preinstall scripts\nWhen a project has a preinstall script (e.g. pnpm dlx only-allow pnpm), corepack use pnpm@latest can crash during the install phase. The child shell trying to run pnpm from the PATH cannot find it because the shim is being re-linked or locked by the main corepack process. This aborts the installation and can leave shims broken.\n\n### Issue 2: Incorrect Prerelease Selection (#774)\nRunning corepack use pnpm without a version often resolves to the newest prerelease (e.g. 11.0.0-dev.1005) instead of the latest stable (e.g. 10.4.1) because * matches prereleases in satisfiesWithPrereleases and semver comparison makes the prerelease 'higher' than the previous stable. This is especially problematic when the prerelease changes internal binary paths (e.g. from .cjs to .mjs), causing shims to break with MODULE_NOT_FOUND.\n\n### Changes\n1. Update
esolveDescriptor in Engine.ts to prefer stable versions if the requested range does not explicitly have a prerelease tag.\n2. Add isPrereleaseRange helper in semverUtils.ts to detect ranges targeting prereleases.\n3. In
unVersion (and �xecutePackageManagerRequest), use COREPACK_PACKAGE_MANAGER_LOCATOR environment variable to ensure sub-invocations use the same binary version, bypassing PATH/shim race conditions.

1. Update resolveDescriptor to prefer stable matching versions unless the range explicitly targets prereleases.
2. Introduce COREPACK_PACKAGE_MANAGER_LOCATOR environment variable to ensure sub-invocations during install phases use the same binary version, bypassing shim race conditions.
3. Fix Descriptor vs Locator type error in executePackageManagerRequest.
4. Add isPrereleaseRange helper in semverUtils.
@AMDphreak AMDphreak closed this Mar 3, 2026
@AMDphreak AMDphreak deleted the fix/prerelease-selection-and-deadlock branch March 3, 2026 19:43
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.

1 participant