Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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.

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();