Skip to content

fix: eagerly require promise-retry to survive self-upgrade#9152

Merged
owlstronaut merged 1 commit intorelease/v10from
fix/eager-require-promise-retry
Mar 27, 2026
Merged

fix: eagerly require promise-retry to survive self-upgrade#9152
owlstronaut merged 1 commit intorelease/v10from
fix/eager-require-promise-retry

Conversation

@owlstronaut
Copy link
Copy Markdown
Contributor

@owlstronaut owlstronaut commented Mar 26, 2026

Running npm install -g npm@latest on Node 22.22.2 (which bundles npm 10.9.7) fails with MODULE_NOT_FOUND: promise-retry.

This happens because npm 11.12.0 removed promise-retry from its bundle (in favor of @gar/promise-retry). During the self-upgrade, the reify step deletes promise-retry from disk, then the still-running 10.x process hits a lazy require('promise-retry') in _linkBins and 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

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
@owlstronaut owlstronaut requested a review from a team as a code owner March 26, 2026 17:46
@owlstronaut
Copy link
Copy Markdown
Contributor Author

CI expected to fail for 22.x

@owlstronaut owlstronaut merged commit 8aa9c82 into release/v10 Mar 27, 2026
59 of 68 checks passed
@owlstronaut owlstronaut deleted the fix/eager-require-promise-retry branch March 27, 2026 15:28
@github-actions github-actions bot mentioned this pull request Mar 27, 2026
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.

2 participants