Repository navigation
fix(cache): store Web Cache under origin data - #36145
Merged
Merged
Conversation
bartlomieju
approved these changes
Jul 20, 2026
bartlomieju
left a comment
Member
There was a problem hiding this comment.
Approve — correct, well-scoped, and consistent with existing invariants. A few optional notes below.
Correctness
- The
origin_data_folder_path.unwrap()invariant matches the pre-existingorigin_storage_dircode directly above it, so this reuses an established invariant rather than adding a new panic path. 👍 - Both worker factories are updated and the only other caller (
cli/tools/info.rs) is too — no stragglers on the old signature. - In
info.rs,web_cache_diris intentionally computed from the un-suffixedorigin_dir(before the--locationhash is applied), so the displayed root matches the real on-disk root. Consistent, just worth a second glance.
Security / robustness (optional)
- The symlink check guards only the leaf component;
create_dir_allwill still traverse a symlinked intermediate (e.g. ifweb_cacheitself were a symlink). Fine as defense-in-depth underDENO_DIR, but a one-line comment noting the leaf-only scope would help future readers. set_permissions(0o700)is re-applied on every open (idempotent, harmless — arguably desirable). Note it applies only to the leaf hash dir; theweb_cacheparent is created with default umask.
Migration note (not a bug)
- Existing caches in
$TMPDIR/deno_cacheare silently orphaned — a one-time effective cache reset. Inherent to the fix and fine, but worth a line in the changelog/PR description so it isn't mistaken for corruption.
Tests look great — the permissions test pre-loosens to 0o777 to prove the tightening happens, and tempfile is correctly a dev-dependency.
bartlomieju
pushed a commit
that referenced
this pull request
Jul 23, 2026
## Summary - store Cache API data beneath Deno's origin-data directory - reject redirected final cache directories and use owner-only Unix modes - update `deno info` output and cover the persisted location end to end ## Details The Web Cache implementation stored its SQLite metadata and response bodies in a system temporary directory, independently of the selected Deno cache and origin-data location. This also made otherwise persistent Cache API state subject to temporary-directory lifecycle. Cache API state now lives under `<DENO_DIR>/location_data/web_cache`, with the existing storage-key hash separating individual stores. Directory setup validates the final path before opening the database. ## Validation - `./tools/format.js --check` - `cargo test -p deno_cache cache_storage_dir` - `cargo test -p deno_lib cache_storage_dir_is_under_origin_data` - `cargo test -p integration_tests --test integration -- web_cache_is_stored_under_deno_dir --nocapture` - `cargo test -p integration_tests --test integration -- cache_put_overwrite --nocapture` - `cargo test -p specs_tests --test specs -- info::flag --nocapture` - `cargo test -p specs_tests --test specs -- info::json --nocapture` - `cargo check -p deno_lib -p deno_cache` - `cargo clippy -p deno_cache --tests -- -D warnings` AI assistance was used to help implement and test this change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
deno infooutput and cover the persisted location end to endDetails
The Web Cache implementation stored its SQLite metadata and response bodies in
a system temporary directory, independently of the selected Deno cache and
origin-data location. This also made otherwise persistent Cache API state
subject to temporary-directory lifecycle.
Cache API state now lives under
<DENO_DIR>/location_data/web_cache, with theexisting storage-key hash separating individual stores. Directory setup
validates the final path before opening the database.
Validation
./tools/format.js --checkcargo test -p deno_cache cache_storage_dircargo test -p deno_lib cache_storage_dir_is_under_origin_datacargo test -p integration_tests --test integration -- web_cache_is_stored_under_deno_dir --nocapturecargo test -p integration_tests --test integration -- cache_put_overwrite --nocapturecargo test -p specs_tests --test specs -- info::flag --nocapturecargo test -p specs_tests --test specs -- info::json --nocapturecargo check -p deno_lib -p deno_cachecargo clippy -p deno_cache --tests -- -D warningsAI assistance was used to help implement and test this change.