serialize npm fetches to survive proxy connection resets
behind Zscaler each package fetch takes 40-50s; npm's default parallel sockets pile up and the proxy resets them mid-stream, aborting npm with 'Exit handler never called' and a truncated node_modules. maxsockets=1 serializes fetches so each completes; a whole-command retry loop rides out any residual transient reset. verified with a --no-cache build: npm ci completes in ~55s and vite build succeeds.
This commit is contained in:
21
Dockerfile
21
Dockerfile
@@ -46,13 +46,15 @@ COPY frontend/package*.json ./frontend/
|
|||||||
# does not warn about a missing cert path; a proxy-inspected build still gets
|
# does not warn about a missing cert path; a proxy-inspected build still gets
|
||||||
# the cert because the file is present.
|
# the cert because the file is present.
|
||||||
# Install the frontend dependencies. vite and the rest of the build toolchain
|
# Install the frontend dependencies. vite and the rest of the build toolchain
|
||||||
# live under devDependencies, so include them explicitly (--include=dev) in case
|
# live under devDependencies, so include them explicitly (--include=dev).
|
||||||
# the environment defaults npm to omit=dev. Behind an inspecting proxy (Zscaler)
|
# Behind an inspecting proxy (Zscaler) each package fetch is slow (40-50s) and
|
||||||
# npm's many parallel fetches intermittently drop, and npm can even abort with
|
# npm's default concurrency piles up parallel sockets that the proxy resets
|
||||||
# "Exit handler never called", leaving an incomplete node_modules with no vite.
|
# mid-stream, making npm abort with "Exit handler never called" and leaving an
|
||||||
# Raise fetch retries/timeouts to ride out flaky connections, then hard-verify
|
# incomplete node_modules with no vite. Serializing to a single socket
|
||||||
# that the toolchain actually landed so the failure is loud and immediate here
|
# (maxsockets 1) lets every fetch complete; the retry loop and raised timeouts
|
||||||
# rather than a confusing "vite: not found" three steps later.
|
# ride out any remaining transient reset, and the final test hard-verifies the
|
||||||
|
# toolchain landed so a truncated install fails loudly here rather than as a
|
||||||
|
# confusing "vite: not found" three steps later.
|
||||||
RUN if [ -f /usr/local/share/ca-certificates/corp-root-ca.crt ]; then \
|
RUN if [ -f /usr/local/share/ca-certificates/corp-root-ca.crt ]; then \
|
||||||
export NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/corp-root-ca.crt; \
|
export NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/corp-root-ca.crt; \
|
||||||
fi; \
|
fi; \
|
||||||
@@ -62,7 +64,10 @@ RUN if [ -f /usr/local/share/ca-certificates/corp-root-ca.crt ]; then \
|
|||||||
npm config set fetch-retry-mintimeout 20000 && \
|
npm config set fetch-retry-mintimeout 20000 && \
|
||||||
npm config set fetch-retry-maxtimeout 120000 && \
|
npm config set fetch-retry-maxtimeout 120000 && \
|
||||||
npm config set fetch-timeout 600000 && \
|
npm config set fetch-timeout 600000 && \
|
||||||
npm ci --include=dev --no-audit --no-fund && \
|
npm config set maxsockets 1 && \
|
||||||
|
( npm ci --include=dev --no-audit --no-fund \
|
||||||
|
|| { echo "npm ci attempt 1 failed, retrying..."; sleep 5; npm ci --include=dev --no-audit --no-fund; } \
|
||||||
|
|| { echo "npm ci attempt 2 failed, retrying..."; sleep 10; npm ci --include=dev --no-audit --no-fund; } ) && \
|
||||||
test -x node_modules/.bin/vite || { \
|
test -x node_modules/.bin/vite || { \
|
||||||
echo "ERROR: node_modules/.bin/vite missing after npm ci (proxy likely truncated the install)."; \
|
echo "ERROR: node_modules/.bin/vite missing after npm ci (proxy likely truncated the install)."; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
|
|||||||
Reference in New Issue
Block a user