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]: Bazel Fails to Fetch [email protected] Due to HTTP 304 Not Modified Error #2021

Open
Blerr511 opened this issue Nov 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Blerr511
Copy link

What happened?

I'm encountering an issue where Bazel fails to fetch the [email protected] package when using the npm_translate_lock rule from Aspect's rules_js. The build process halts with an error indicating that a GET request returned a 304 Not Modified status code, which Bazel does not handle properly.

This issue seems specific to the fast-deep-equal package, as other packages are fetched without any problems.

WARNING: Download from https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 304 Not Modified
INFO: Repository npm__fast-deep-equal__3.1.3 instantiated at:
  /home/user/project/WORKSPACE:113:17: in <toplevel>
  /home/user/.cache/bazel/_bazel_user/xxxxxxxx/external/npm/repositories.bzl:49826:15: in npm_repositories
  /home/user/.cache/bazel/_bazel_user/xxxxxxxx/external/aspect_rules_js/npm/private/npm_import.bzl:1154:20: in npm_import
Repository rule npm_import_rule defined at:
  /home/user/.cache/bazel/_bazel_user/xxxxxxxx/external/aspect_rules_js/npm/private/npm_import.bzl:865:34: in <toplevel>
ERROR: An error occurred during the fetch of repository 'npm__fast-deep-equal__3.1.3':
   Traceback (most recent call last):
   	File "/home/user/.cache/bazel/_bazel_user/xxxxxxxx/external/aspect_rules_js/npm/private/npm_import.bzl", line 501, column 38, in _npm_import_rule_impl
   		_download_and_extract_archive(rctx, package_json_only = True)
   	File "/home/user/.cache/bazel/_bazel_user/xxxxxxxx/external/aspect_rules_js/npm/private/npm_import.bzl", line 437, column 18, in _download_and_extract_archive
   		rctx.download(
Error in download: java.io.IOException: Error downloading [https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz] to /home/user/.cache/bazel/_bazel_user/xxxxxxxx/external/npm__fast-deep-equal__3.1.3/package.tgz: GET returned 304 Not Modified
ERROR: no such package '@@npm__fast-deep-equal__3.1.3//': java.io.IOException: Error downloading [https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz] to /home/user/.cache/bazel/_bazel_user/xxxxxxxx/external/npm__fast-deep-equal__3.1.3/package.tgz: GET returned 304 Not Modified
ERROR: /home/user/project/BUILD.bazel:6:22: //:.aspect_rules_js/node_modules/[email protected]/pkg depends on @@npm__fast-deep-equal__3.1.3//:pkg in repository @@npm__fast-deep-equal__3.1.3 which failed to fetch. no such package '@@npm__fast-deep-equal__3.1.3//': java.io.IOException: Error downloading [https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz]...

I've tried bazel clean --expunge , it doesn't help

Version

Bazel Version: 7.2.1 or 6.1.2
rules_ts Version: rules_ts-3.2.0
Operating System: Ubuntu 24.04.1 LTS
Node.js Version: 18.18.2
NPM Version: 9.8.1
PNPM Version: 8.3.1

How to reproduce

1. Set up a Bazel workspace and BUILD files
2. Include [email protected] as a dependency in your package.json and pnpm-lock.yaml
3. Run a Bazel build command that triggers the fetching of NPM packages:

Any other information?

Here is a minimal codebase for reproducing the issue

https://github.com/Blerr511/bazel-npm-import-issue

@Blerr511 Blerr511 added the bug Something isn't working label Nov 17, 2024
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

1 participant