Skip to content

[Bug]: Bazel Fails to Fetch [email protected] Due to HTTP 304 Not Modified Error #2021

Open
@Blerr511

Description

@Blerr511

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions