-
Notifications
You must be signed in to change notification settings - Fork 5.6k
fix(npm): respect etag for npm packument caching #29130
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes npm packument caching by respecting ETag headers. It computes an ETag for registry JSON files using a SHA256 hash (encoded in Base64) and returns a 304 Not Modified response when the “If-None-Match” header matches the computed ETag.
- Introduced ETag computation and checking in the npm registry server.
- Updated cache structures and HTTP client interfaces in the npm_cache resolvers.
- Renamed and adjusted authentication header helper functions for consistency.
Reviewed Changes
Copilot reviewed 16 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
tests/util/server/src/servers/npm_registry.rs | Added ETag computation and response handling based on the “If-None-Match” header. |
resolvers/npm_cache/tarball.rs | Updated FTP traits and HTTP client call to handle the new ETag logic. |
resolvers/npm_cache/remote.rs | Renamed and simplified the auth header helper to return a raw string value. |
resolvers/npm_cache/registry_info.rs | Introduced a new SerializedCachedPackageInfo struct with a _deno.etag property. |
resolvers/npm_cache/lib.rs | Adjusted HTTP client response types and updated download logic to accommodate ETag. |
cli/* | Minor adaptations to propagate the updated HTTP client and caching API changes. |
Files not reviewed (3)
- tests/specs/npm/packument_etag/test.jsonc: Language not supported
- tests/specs/npm/packument_etag/install_reload.out: Language not supported
- tests/specs/npm/packument_etag/package.json: Language not supported
// todo(dsherret): deserialize in a blocking task | ||
serde_json::from_slice(&file_bytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you want to do it in a blocking task? If so, should it be done in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we can parallelize it like we do elsewhere. I want to see and measure its affects in a followup pr.
Stores the etag in a
_deno.etag
property on the json object of the packument.#[serde(flatten)]
deno_npm#104Closes #24566