Skip to content

Commit a2fafd3

Browse files
authored
fix: cache bust http cache on lockfile integrity mismatch (#28087)
Cache busts the http cache when the lockfile integrity doesn't match what's in the cache. This will help when someone's lockfile is in line with the remote server, but their local cache isn't.
1 parent adf461f commit a2fafd3

File tree

12 files changed

+47
-4
lines changed

12 files changed

+47
-4
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ deno_config = { workspace = true, features = ["sync", "workspace"] }
7272
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
7373
deno_doc = { version = "=0.164.0", features = ["rust", "comrak"] }
7474
deno_error.workspace = true
75-
deno_graph = { version = "=0.87.2" }
75+
deno_graph = { version = "=0.87.3" }
7676
deno_lib.workspace = true
7777
deno_lint = { version = "0.72.0" }
7878
deno_lockfile.workspace = true

tests/specs/lockfile/auto_discover_lockfile/main.out

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Download http://localhost:4545/subdir/mod2.ts
22
Download http://localhost:4545/subdir/print_hello.ts
3+
Download http://localhost:4545/subdir/print_hello.ts
34
error: Integrity check failed for remote specifier. The source code is invalid, as it does not match the expected hash in the lock file.
45

56
Specifier: http://localhost:4545/subdir/print_hello.ts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"tempDir": true,
3+
"envs": {
4+
"DENO_DIR": "./deno_dir"
5+
},
6+
"steps": [{
7+
"args": "cache --allow-import main.ts",
8+
"output": "[WILDCARD]"
9+
}, {
10+
"args": "run -A update.ts",
11+
"output": "[WILDCARD]"
12+
}, {
13+
"args": "run --allow-import main.ts",
14+
"output": "main.out"
15+
}]
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"lock": {
3+
"frozen": true
4+
}
5+
}

tests/specs/lockfile/cache_bust_integrity_failure/deno.lock

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[# should download because it cache busts]
2+
Download http://localhost:4545/welcome.ts
3+
Welcome to Deno!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "http://localhost:4545/welcome.ts";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// make the path in the deno_dir differ from the remote server
2+
// and what's stored in the lockfile
3+
const filePath =
4+
"./deno_dir/remote/http/localhost_PORT4545/3011c891e5bd4172aa2e157e4c688ab6f31e91da9719704a9a54aa63faa99c88";
5+
const text = Deno.readTextFileSync(filePath);
6+
Deno.writeTextFileSync(filePath, "//\n" + text);

tests/specs/lockfile/no_lock/fail.out

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Download http://localhost:4545/lockfile/basic/mod.ts
2+
Download http://localhost:4545/lockfile/basic/mod.ts
23
error: Integrity check failed for remote specifier. The source code is invalid, as it does not match the expected hash in the lock file.
34

45
Specifier: http://localhost:4545/lockfile/basic/mod.ts

tests/specs/run/wasm_module/integrity_check_failed/main.out

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Download http://localhost:4545/wasm/math.wasm
2+
Download http://localhost:4545/wasm/math.wasm
23
error: Integrity check failed for remote specifier. The source code is invalid, as it does not match the expected hash in the lock file.
34

45
Specifier: http://localhost:4545/wasm/math.wasm

tests/util/server/src/assertions.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ pub fn assert_wildcard_match_with_logger(
6565
expected: &str,
6666
logger: &mut dyn Write,
6767
) {
68-
if !expected.contains("[WILD") && !expected.contains("[UNORDERED_START]") {
68+
if !expected.contains("[WILD")
69+
&& !expected.contains("[UNORDERED_START]")
70+
&& !expected.contains("[#")
71+
{
6972
pretty_assertions::assert_eq!(actual, expected);
7073
} else {
7174
match crate::wildcard_match_detailed(expected, actual) {

0 commit comments

Comments
 (0)