Skip to content

Commit

Permalink
Merge pull request #18 from Canva/christianscott-yarn_increase_mutex_…
Browse files Browse the repository at this point in the history
…timeout

patch yarn to increase network mutex timeout
  • Loading branch information
christianscott authored Nov 15, 2023
2 parents 97ad57a + 0c0851e commit ab6ec09
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/node/node_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ If this list is empty, we won't download yarn at all.
doc = "the specific version of Yarn to install",
default = "1.19.1",
),
"_yarn_increase_mutex_timeout_patch": attr.label(default = "//internal/npm_install:yarn-increase-mutex-timeout.patch"),
}

BUILT_IN_NODE_PLATFORMS = [
Expand Down Expand Up @@ -381,6 +382,9 @@ def _download_yarn(repository_ctx):
sha256 = sha256,
))

patch_path = repository_ctx.path(repository_ctx.attr._yarn_increase_mutex_timeout_patch)
repository_ctx.execute(["patch", "lib/cli.js", patch_path], working_directory = YARN_EXTRACT_DIR)

def _prepare_node(repository_ctx):
"""Sets up BUILD files and shell wrappers for the versions of NodeJS, npm & yarn just set up.
Expand Down
23 changes: 23 additions & 0 deletions internal/npm_install/yarn-increase-mutex-timeout.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
See https://github.com/yarnpkg/yarn/issues/8960
TL;DR - NodeJS 18 made `http` timeout connections that don't send headers after 90s
But some installations can take much longer than that - so if we have another mutex blocked waiting for that install it will
silently die with exit code 0. Bazel sees this as a success (ofc) then proceeds as if the install succeeded, then dies because
obviously the install did not succeed (or even begin).

diff --git a/lib/cli.js b/lib/cli.js
--- a/lib/cli.js
+++ b/lib/cli.js
@@ -88432,7 +88432,12 @@ var main = exports.main = function () {

function startServer() {
var clients = new (_set || _load_set()).default();
- var server = (_http || _load_http()).default.createServer(manager);
+ var server = (_http || _load_http()).default.createServer({
+ // https://github.com/yarnpkg/yarn/issues/8960
+ // this bumps that timeout to the default 5 minutes
+ headersTimeout: 300000,
+ requestTimeout: 300000,
+ }, manager);

// The server must not prevent us from exiting
server.unref();

0 comments on commit ab6ec09

Please sign in to comment.