在更新过程中出现错误:ESOCKETTIMEDOUT registry.yarnpkg.com

正在尝试通过手动过程更新 Discourse

git pull
./launcher rebuild app
...

./discourse-doctor 显示错误

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 ====================

当我尝试运行时出现相同问题
./launcher rebuild app

我尝试在 Linux 主机上下载 date-fns-2.29.3.tgz,并且成功了。

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 托管在 Alpine Linux VM 上

我在ubuntu vps上也遇到了同样的问题。毫无头绪。

我无法确定这是真正的问题,还是您在 Docker 网络方面存在问题。

1 个赞

这可能可以通过在 yarn 放弃之前增加更多时间来解决。我已提交一个拉取请求:

您可以按照 Mario Lurig 的说明手动进行此更改:

另请参阅:

3 个赞

太棒了。引用以永久保存和搜索:

但是,当我等待第 9 步完成(在运行 ./discourse-setup 并完成所有构建后)时,它会因与 yarn 相关的 ESOCKETTIMEDOUT 错误而失败。最后一条尝试运行的消息是 [ ! -d 'node_modules' ] || su discourse -c 'yarn install --production \u0026\u0026 yarn cache clean'

修复方法

您需要安装一个编辑器;我更喜欢 nano,所以 apt-get install nano 就可以解决问题。然后转到 /var/discourse/templates 并运行:nano web.template.yml。为了进行比较,这是您从 github 克隆的文件,感兴趣的区域大约在第 159 行。看起来熟悉吗?它与上面提到的失败前的命令相同。我们需要在此行上方添加一个新部分以增加超时时间。

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

保存此更改,然后重新运行 ./discourse-setup,瞧,就完成了!这肯定需要一段时间,尤其是 brotli 压缩步骤,但它会完成。

3 个赞

我遇到了同样的超时问题,但在实现建议的解决方案时遇到了一些困难,因此我想添加一些细节。

首先,我花了些时间才找到 /var/discourse/templates,因为我的 Discourse 安装在非标准位置。我当时在 Docker 中查找,这当然没有意义。

其次,第 159 行不再正确。我猜您指的是 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 &amp;&amp; yarn cache clean'

第三,我对 yaml、pups 和 yarn 不是很熟悉,也不知道它们在 Discourse 中是如何使用的,而且我不想猜测。因此,我尝试对原始部分进行了如下更改:

  - 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 &amp;&amp; yarn install --frozen-lockfile &amp;&amp; yarn cache clean'

这对我来说是有效的。./launcher rebuild app 现在需要很长时间(对我来说超过 2 小时),但至少它能成功完成,并且论坛又能正常工作了。

最后,我想补充一点,这个问题(对我而言)绝对不是内存不足:我使用的是带有 32GB 内存的 VPS,问题发生时有 24GB 是空闲的。

2 个赞