Error during the update ESOCKETTIMEDOUT registry.yarnpkg.com

Trying to update Discourse via the manual procedure

git pull
./launcher rebuild app
...

./discourse-doctor shows an error

I, [2023-06-16T11:39:43.530890 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'yarn install --frozen-lockfile && yarn cache clean'
error An unexpected error occurred: "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz: ESOCKETTIMEDOUT".
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'yarn install --frozen-lockfile && yarn cache clean' failed with return #<Process::Status: pid 281 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "cmd"=>["su discourse -c 'yarn install --frozen-lockfile && yarn cache clean'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
f485460571ab9e30e0d6917b05c9a8fe1772df13d8cae9fe67108961fae71039
==================== END REBUILD LOG ====================

The same problem when I tried to run
./launcher rebuild app

I tried downloading date-fns-2.29.3.tgz on a Linux host, and it works.

wget https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz
Connecting to registry.yarnpkg.com (104.16.26.35:443)
saving to 'date-fns-2.29.3.tgz'
date-fns-2.29.3.tgz  100% |*************************************************************************************************************|  712k  0:00:00 ETA
'date-fns-2.29.3.tgz' saved

Discourse hosted on Alpine Linux VM

I encounter the same issue on ubuntu vps. not any clue.

I can’t tell if that’s the real issue or if you have an issue with docker networking.

1 Like

It’s possible this could be fixed by adding more time before yarn gives up. I’ve submitted a pull request:

You can make this change manually as explained by Mario Lurig:

See also:

3 Likes

Excellent. Quoted for permanence and search:

However, when I was waiting for Step 9 to complete (after running ./discourse-setup) and everything being built, it would fail with an ESOCKETTIMEDOUT error related to yarn. The last message that tries to run is [ ! -d 'node_modules' ] || su discourse -c 'yarn install --production && yarn cache clean'.

The Fix

You need to install an editor; I prefer nano so apt-get install nano does the trick. Then go to /var/discourse/templates and run: nano web.template.yml. For comparison, here is the file you cloned from github and the area of interest is around line 159. Look familiar? It’s the same command noted above before it failed. We need to add a new section above this line to increase the timeout.

  • exec: cd: $home cmd: - “su discourse -c ‘yarn config set network-timeout 600000 -g’”

Save this change then rerun ./discourse-setup and viola, completion! It will definitely take a while, especially the brotli compression step, but it will finish.

3 Likes

I had the same timeout, but I had problems to implement the suggested solution, so I’d like to add some details.

First, I had some trouble to find /var/discourse/templates, because my Discourse installation is in a non-standard location. I was looking inside Docker, which of course makes no sense.

Second, line number 159 is no longer correct. I assume you are referring to this section of template.yml:

- exec:
      cd: $home
      hook: yarn
      cmd:
        - |-
          if [ "$version" != "tests-passed" ]; then
            rm -rf app/assets/javascripts/node_modules
          fi
        - su discourse -c 'yarn install --frozen-lockfile && yarn cache clean'

Third, I am not very familiar with yaml, pups and yarn or how these are used in Discourse, and I didn’t want to guess. Instead, I tried this change to the original section:

  - exec:
      cd: $home
      hook: yarn
      cmd:
        - |-
          if [ "$version" != "tests-passed" ]; then
            rm -rf app/assets/javascripts/node_modules
          fi
        - su discourse -c 'yarn config set network-timeout 600000 -g && yarn install --frozen-lockfile && yarn cache clean'

This works for me. ./launcher rebuild app now takes a very long time (more than 2 hours for me), but at least it runs to completion, and the forum works again.

Finally, I’d like to add that this issue (for me) was certainly not a lack of memory: I am using a VPS with 32GB installed, of which 24GB were free when the problem occurred.

1 Like