Repository navigation
Make aspnetcore npm ci restore robust to transient failures - #7361
Merged
Merged
Conversation
The 'npm ci' step in eng/Npm.Workspace.nodeproj fails non-deterministically when a transient network error (e.g. ECONNRESET while reading the response body) occurs against the npm registry. npm's built-in fetch-retries does not reliably recover from body-read errors, so a single hiccup fails the build. Wrap 'npm ci' in a node retry helper (eng/scripts/npm/npm-ci-retry.mjs) that retries with backoff before failing. Co-authored-by: Copilot <[email protected]>
wtgodbe
approved these changes
Jun 24, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Improves reliability of the VMR unified build by making the aspnetcore NPM restore step resilient to transient npm ci failures, avoiding full-build reruns caused by flaky network/Node exits.
Changes:
- Add a cross-platform Node.js retry wrapper that runs
npm ciup to 5 times with linear backoff. - Update the aspnetcore
RestoreMSBuild target to invoke the retry wrapper instead of callingnpm cidirectly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/aspnetcore/eng/scripts/npm/npm-ci-retry.mjs | New retry wrapper script that runs npm ci with backoff and retries. |
| src/aspnetcore/eng/Npm.Workspace.nodeproj | Switches the Restore target from npm ci to the new retry wrapper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mmitche
enabled auto-merge (squash)
June 24, 2026 22:00
Member
|
could we make an arcade |
This was referenced Jun 26, 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.
Summary
Makes the aspnetcore
npm cirestore step resilient to transientnpm cifailures that non-deterministically break the VMR build.The
Restoretarget insrc/aspnetcore/eng/Npm.Workspace.nodeprojinvokesnpm cidirectly. Whennpm ciexits non-zero for a transient reason, the whole multi-hour unified build fails and must be manually re-run. Observed manifestations:ECONNRESET/ "Invalid response body while trying to fetch ..." while pulling packages from thedotnet-public-npmfeed..npmrcalready setsfetch-retries=5, but npm's built-in retry does not reliably recover from errors that occur while reading the response body — so a single body-read reset fails the command.npm ciexiting with code57005(0xDEAD) — an abnormal Node/Windows exit with no network diagnostic.Fix
Wrap
npm ciin a small cross-platform node retry helper,src/aspnetcore/eng/scripts/npm/npm-ci-retry.mjs, and call it from theRestoretarget instead of invokingnpm cidirectly.ECONNRESET) and abnormal-exit (0xDEAD) cases above.npm ciis a clean install, so re-running between attempts is safe.pack-workspace.mjsscripts, so no new dependency is introduced.Expected impact
I analyzed every
dotnet-unified-buildrun onmainandrelease/*queued in the last 30 days (internal pipeline, definition 1330), across all result types, inspecting every attempt (final + all retriedpreviousAttemptstimelines) for an aspnetcorenpm cifailure:The two covered builds:
3007299(release/11.0.1xx-preview6) — exit 1,ECONNRESET/ "Invalid response body"2992464(release/11.0.1xx-preview5) — exit57005(0xDEAD)Notes:
npm ciand changes no package manifests.Note on canonical location
This file is mirrored from dotnet/aspnetcore (
eng/Npm.Workspace.nodeproj,eng/scripts/npm/). The durable fix should also land upstream so it survives code flow; this PR is raised against the VMR per request.