fix: eagerly require promise-retry to survive self-upgrade#9152
Merged
owlstronaut merged 1 commit intorelease/v10from Mar 27, 2026
Merged
fix: eagerly require promise-retry to survive self-upgrade#9152owlstronaut merged 1 commit intorelease/v10from
owlstronaut merged 1 commit intorelease/v10from
Conversation
When npm 10.x upgrades itself to npm 11.12+, the new npm no longer bundles promise-retry. The lazy require in _linkBins fires after the reify step has already deleted promise-retry from disk, causing MODULE_NOT_FOUND. Moving the require to the top of the file ensures it is loaded at startup while the module still exists on disk. Fixes: #9151 Ref: nodejs/node#62425
Contributor
Author
|
CI expected to fail for 22.x |
2 tasks
reggi
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Running
npm install -g npm@lateston Node 22.22.2 (which bundles npm 10.9.7) fails withMODULE_NOT_FOUND: promise-retry.This happens because npm 11.12.0 removed
promise-retryfrom its bundle (in favor of@gar/promise-retry). During the self-upgrade, the reify step deletespromise-retryfrom disk, then the still-running 10.x process hits a lazyrequire('promise-retry')in_linkBinsand blows up.That lazy require was introduced in #9011 as part of the retry-on-Windows backport, it was just placed inline next to where it's used, no functional reason for it to be lazy.
Moving it to the top of the file with the other imports means it gets loaded at startup while the file still exists. The captured reference survives the upgrade.
Tested on a fresh Node 22.22.2: unpatched fails, patched upgrades to 11.12.0 cleanly.
Fixes #9151
Ref nodejs/node#62425