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

[Bug]: js_run_binary tool runfiles get built twice #2073

Open
jfirebaugh opened this issue Jan 16, 2025 · 0 comments
Open

[Bug]: js_run_binary tool runfiles get built twice #2073

jfirebaugh opened this issue Jan 16, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@jfirebaugh
Copy link
Contributor

jfirebaugh commented Jan 16, 2025

What happened?

js_run_binary sets use_execroot_entry_point = True by default, and hoists runfiles of the tool to srcs so that they are included as execroot inputs to the action, while also preserving the runfiles input. The downside of this is that any actions required to build those runfiles will get executed twice: once under the default fastbuild configuration, for the execroot input, and once under a transition, for the runfiles input. For example, if there are npm packages in the runfiles dependencies, then their NpmPackageExtract (and NpmLifecycleHook if present) actions run twice.

I was able to work around this in a specific case where it had a significant performance impact by avoiding the use of data dependencies, but it would be nice if there was a generic solution such that every use of js_run_binary would not be affected by default.

Version

Development (host) and target OS/architectures:

Output of bazel --version: bazel 7.4.0

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file: rules_js 2.1.2

Language(s) and/or frameworks involved: JS

How to reproduce

In rules_js, run bazel clean && bazel build --execution_log_compact_file=compact_exec.log //examples/js_binary:run2 && ../bazel/bazel-bin/src/tools/execlog/parser --log_path compact_exec.log.

acorn/CHANGELOG.md output from first NpmPackageExtract, in darwin_arm64-fastbuild:

actual_outputs {
  path: "bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/[email protected]/node_modules/acorn/CHANGELOG.md"
  digest {
    hash: "6767297d491d22ed8897c4df234d0f83ee0258091066ce344102effdba304c9f"
    size_bytes: 17478
    hash_function_name: "SHA-256"
  }
}

acorn/CHANGELOG.md output from second NpmPackageExtract, in darwin_arm64-opt-exec-ST-d57f47055a04:

actual_outputs {
  path: "bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/node_modules/.aspect_rules_js/[email protected]/node_modules/acorn/CHANGELOG.md"
  digest {
    hash: "6767297d491d22ed8897c4df234d0f83ee0258091066ce344102effdba304c9f"
    size_bytes: 17478
    hash_function_name: "SHA-256"
  }
}

First acorn/CHANGELOG.md input:

inputs {
  path: "bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/[email protected]/node_modules/acorn/CHANGELOG.md"
  digest {
    hash: "6767297d491d22ed8897c4df234d0f83ee0258091066ce344102effdba304c9f"
    size_bytes: 17478
    hash_function_name: "SHA-256"
  }
}

Second acorn/CHANGELOG.md input:

inputs {
  path: "bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/examples/js_binary/bin_/bin.runfiles/_main/node_modules/.aspect_rules_js/[email protected]/node_modules/acorn/CHANGELOG.md"
  digest {
    hash: "6767297d491d22ed8897c4df234d0f83ee0258091066ce344102effdba304c9f"
    size_bytes: 17478
    hash_function_name: "SHA-256"
  }
  is_tool: true
}

Any other information?

No response

@jfirebaugh jfirebaugh added the bug Something isn't working label Jan 16, 2025
@jbedard jbedard self-assigned this Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants