chore(build): make Docker npm ci resilient to transient registry network errors#4303
Open
TaprootFreak wants to merge 1 commit into
Open
chore(build): make Docker npm ci resilient to transient registry network errors#4303TaprootFreak wants to merge 1 commit into
TaprootFreak wants to merge 1 commit into
Conversation
…ork errors A single npm-registry ECONNRESET during `RUN npm ci` aborted a DEV-deploy build. npm defaults are weak (fetch-retries=2, short timeouts), so one transient blip fails the whole build/deploy. Add a repo-root .npmrc with network-resilience settings only (no registry/auth) and ADD it before npm ci in the builder stage so the config is in effect. Also hardens the CI build+test job and local dev via a single source of truth.
Collaborator
Author
|
Root-cause fix for the transient |
TaprootFreak
marked this pull request as ready for review
July 21, 2026 15:05
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.
Problem
A DEV-deploy build recently failed on a single
npm error code ECONNRESETduringRUN npm ciin the Docker builder stage. A single transient npm-registry network blip should not fail an entire build/deploy.The root cause is a fragility bug, not a one-off: the builder stage runs
npm ciwith npm defaults (fetch-retries=2, short timeouts) and there is no repo-level.npmrc, so oneECONNRESET/ETIMEDOUTaborts the whole build.Fix (minimal, single source of truth)
Add a repo-root
.npmrcwith network-resilience settings only (no registry override, no auth/tokens):npm retries registry requests on transient network errors (incl.
ECONNRESET/ETIMEDOUT); 5 retries with 20s→120s exponential backoff and a 5-min per-request timeout letnpm cisurvive a blip.Dockerfile:ADD --chown=node:node .npmrc .on the line beforeRUN npm ci, so the builder stage actually reads the config (previously onlypackage.json+package-lock.jsonwere ADDed beforenpm ci).package.json/package-lock.jsonare untouched. Because the.npmrcsits at the repo root, it also transparently hardens the CI Build-and-test job (npm ciruns in the checkout) and local dev — one source of truth.Verification (docker build on arm64)
docker build --target builder -t dfx-api-npmrc-test .→ builder stage completesnpm cisuccessfully with the.npmrcpresent; image builds clean.docker run --rm dfx-api-npmrc-test npm config get fetch-retries→5(alsofetch-retry-maxtimeout→120000,fetch-timeout→300000), proving the.npmrcis in effect duringnpm ci.