denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
94.97k stars 5.27k forks source link

Make `deno install` automatically retry network requests. #26085

Open Weldawadyathink opened 1 day ago

Weldawadyathink commented 1 day ago

I have been porting a project to deno, and my current internet connection is slightly unstable. Because of this, deno install will randomly fail a network request. This is causing a lot of issues building my docker containers. The errors always look something like this:

0.094 Download https://registry.npmjs.org/yaml
0.094 Download https://registry.npmjs.org/word-wrap
0.094 Download https://registry.npmjs.org/esbuild
0.163 error: failed reading lockfile '/app/deno.lock'
0.163 
0.163 Caused by:
0.163     Error getting response at https://registry.npmjs.org/@alloc/quick-lru for package "@alloc/quick-lru": error sending request for url (https://registry.npmjs.org/@alloc/quick-lru): client error (Connect): tcp connect error: Network is unreachable (os error 101): Network is unreachable (os error 101)
------
Dockerfile:15
--------------------
  13 |     FROM base AS client
  14 |     COPY client/package.json client/deno.lock ./
  15 | >>> RUN deno install --allow-scripts --frozen=true
  16 |     COPY client/ ./
  17 |     RUN deno task build
--------------------
ERROR: failed to solve: process "/bin/sh -c deno install --allow-scripts --frozen=true" did not complete successfully: exit code: 1

It is always a different package that fails, which is why I suspect intermittent network issues. Currently I have to just run docker build over and over until it happens to be successful and docker can cache the layer. If deno were to automatically retry the requests a few times before failing, this issue would be mitigated.

nathanwhit commented 1 day ago

Yup, should definitely do this. I've been hitting this a lot being on hotel wifi. I'll look into this soon