From 0cb5de2d62c6e80d209c7d0e02f130210e5fba94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 31 Dec 2025 07:53:32 +0000 Subject: [PATCH] prefetch-npm-deps: use package name field for aliases npm lockfiles can contain package aliases where the lockfile key differs from the actual package name (e.g., "string-width-cjs" aliasing "string-width"). Previously we always used the lockfile key, causing us to fetch packuments for the wrong package. Use the package's own "name" field when present, falling back to the lockfile key. This ensures we fetch the correct packument for aliased packages, fixing non-deterministic builds where the wrong packument fetch could succeed or fail depending on network timing. --- .../build-support/node/prefetch-npm-deps/src/parse/lock.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/node/prefetch-npm-deps/src/parse/lock.rs b/pkgs/build-support/node/prefetch-npm-deps/src/parse/lock.rs index 17c6c633ee8f..266ba2585913 100644 --- a/pkgs/build-support/node/prefetch-npm-deps/src/parse/lock.rs +++ b/pkgs/build-support/node/prefetch-npm-deps/src/parse/lock.rs @@ -25,7 +25,12 @@ pub(super) fn packages(content: &str) -> anyhow::Result> { .unwrap_or_default() .into_iter() .filter(|(n, p)| !n.is_empty() && matches!(p.resolved, Some(UrlOrString::Url(_)))) - .map(|(n, p)| Package { name: Some(n), ..p }) + .map(|(n, p)| Package { + // Use the package's own name if present (for aliases like string-width-cjs -> string-width), + // otherwise extract from the lockfile key + name: Some(p.name.unwrap_or(n)), + ..p + }) .collect(), _ => bail!( "We don't support lockfile version {}, please file an issue.",