Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate_build_file.ts can fail with EMFILE #3507

Closed
jfirebaugh opened this issue Jul 18, 2022 · 0 comments · Fixed by #3509
Closed

generate_build_file.ts can fail with EMFILE #3507

jfirebaugh opened this issue Jul 18, 2022 · 0 comments · Fixed by #3509

Comments

@jfirebaugh
Copy link
Contributor

jfirebaugh commented Jul 18, 2022

🐞 bug report

Affected Rule

The issue is caused by the rule: npm_install

Is this a regression?

This likely regressed in e3963e1.

Description

generate_build_file.ts performs recursive filesystem operations asynchronously without any form of rate limiting or handling of errors relating to reaching file descriptor limits.

https://github.com/bazelbuild/rules_nodejs/blob/0be0eeb12bd525773f4504c13b5d799e1b2780a1/internal/npm_install/generate_build_file.ts#L689-L705

This can lead to the script failing with an EMFILE error.

🔬 Minimal Reproduction

Unfortunately this issue does not lend itself to a minimal reproduction. It's dependent on size of the node_modules folder and system-specific ulimit configuration. Also, it's non-deterministic.

🔥 Exception or Error


INFO: Repository npm instantiated at:
  /Users/mzhou/figma/figma/WORKSPACE.bazel:85:12: in 
  /private/var/tmp/_bazel_mzhou/529a40494971fd74139c7ccd5277dbfc/external/build_bazel_rules_nodejs/index.bzl:78:17: in npm_install
Repository rule npm_install defined at:
  /private/var/tmp/_bazel_mzhou/529a40494971fd74139c7ccd5277dbfc/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl:786:30: in 
ERROR: An error occurred during the fetch of repository 'npm':
   Traceback (most recent call last):
	File "/private/var/tmp/_bazel_mzhou/529a40494971fd74139c7ccd5277dbfc/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 784, column 24, in _npm_install_impl
		_create_build_files(repository_ctx, "npm_install", node, repository_ctx.attr.package_lock_json, repository_ctx.attr.generate_local_modules_build_files)
	File "/private/var/tmp/_bazel_mzhou/529a40494971fd74139c7ccd5277dbfc/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 490, column 13, in _create_build_files
		fail("generate_build_file.ts failed: \nSTDOUT:\n%s\nSTDERR:\n%s" % (result.stdout, result.stderr))
Error in fail: generate_build_file.ts failed: 
STDOUT:
STDERR:
node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^
[Error: EMFILE: too many open files, open '_/node_modules/@types/babel__generator/package.json'] {
  errno: -24,
  code: 'EMFILE',
  syscall: 'open',
  path: '_/node_modules/@types/babel__generator/package.json'
}

🌍 Your Environment

Operating System:

  

  

Output of bazel version:

  

  

Rules_nodejs version:

5.5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant