diff --git a/internal/node/node_repositories.bzl b/internal/node/node_repositories.bzl index 978ac1de..39a2ee34 100755 --- a/internal/node/node_repositories.bzl +++ b/internal/node/node_repositories.bzl @@ -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 = [ @@ -384,6 +385,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. diff --git a/internal/npm_install/yarn-increase-mutex-timeout.patch b/internal/npm_install/yarn-increase-mutex-timeout.patch new file mode 100644 index 00000000..81f23563 --- /dev/null +++ b/internal/npm_install/yarn-increase-mutex-timeout.patch @@ -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();