fix(npm): reload an npm package's dependency's information when version not found (#18622)

This reloads an npm package's dependency's information when a
version/version req/tag is not found.

This PR applies only to dependencies of npm packages. It does NOT yet
cause npm specifiers to have their dependency information cache busted.
That requires a different solution, but this should help cache bust in
more scenarios.

Part of #16901, but doesn't close it yet
This commit is contained in:
David Sherret 2023-04-06 21:41:19 -04:00 committed by GitHub
parent 0dca0c5196
commit 5c7f76c570
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 257 additions and 57 deletions

View file

@ -117,10 +117,11 @@ pub async fn snapshot_from_lockfile(
let mut version_infos =
FuturesOrdered::from_iter(packages.iter().map(|p| p.pkg_id.nv.clone()).map(
|nv| async move {
match api.package_version_info(&nv).await? {
Some(version_info) => Ok(version_info),
None => {
bail!("could not find '{}' specified in the lockfile. Maybe try again with --reload", nv);
let package_info = api.package_info(&nv.name).await?;
match package_info.version_info(&nv) {
Ok(version_info) => Ok(version_info),
Err(err) => {
bail!("Could not find '{}' specified in the lockfile. Maybe try again with --reload", err.0);
}
}
},