Skip to content

Commit 11a7fdd

Browse files
astegmaierzkochan
andauthored
perf(npm-resolver): cache disk-loaded metadata in memory on offline resolution (#12760)
When resolving with --offline or --prefer-offline, pickPackage loaded a package's metadata from the on-disk cache mirror but never stored it in the in-memory metaCache, so every subsequent resolution of the same package (once per dependent that references it) re-read and re-parsed the full packument from disk. Store the parsed metadata in the in-memory cache on those disk-return paths, so each package's metadata is parsed at most once per command. On a large monorepo this collapses 23,746 metadata loads to 5,124 (66.8 GB of JSON parsed to 8.8 GB) and takes pnpm dedupe --offline from ~140s to ~75s with a byte-identical lockfile. The cache is the existing bounded LRU; online and network paths are untouched. Promotion alone would have made the top-of-function cache hit terminal: a disk-promoted packument that predates a later-requested range would turn a previously-recoverable network fallback into ERR_PNPM_NO_MATCHING_VERSION. Track registry-unverified disk promotions (a WeakSet keyed by object identity in TypeScript; a registry_verified flag carried inside the cache value in pacquet, so meta and state are read atomically) and let a cache hit whose pick fails on such an entry fall through to the regular network-validating flow unless offline. The revalidating fetch stores a verified entry, so each package revalidates at most once. The pre-existing exact-version fast paths on both stacks had the same latent failure mode and are covered by the same marking. Pacquet's PackageMetaCache::set_unverified is a required trait method so custom cache implementations cannot silently inherit the terminal behavior, and the TypeScript PackageMetaCache documents the object-identity contract its WeakSet relies on. Also registry-qualify pacquet's verifier shared-meta-cache reads (read_shared_meta queried bare name keys while the resolver stores registry-qualified ones, so the fast path could never hit), mirroring the TypeScript readSharedMeta lookup order. Add an isolated-linker.fresh-resolve.hot-cache.offline benchmark scenario (install --offline --lockfile-only against a warm mirror, with an untimed online pre-warm pass and per-iteration node_modules + lockfile wipes so the up-to-date short-circuit cannot skip the measured resolution) to guard offline resolution on all Bencher testbeds. Fixing it to measure real work also revived the pnpm benchmark pipeline, silently dead since the pnpm11/ move: bench.sh resolved REPO_ROOT to pnpm11/ where no Cargo.toml exists, the orchestrator probed the pre-move pnpm/dist bundle path, and continue-on-error masked every failure as a green run. The scenario measures this change directly: pnpm@HEAD resolves the fixture offline in 2.41s vs 3.17s for pnpm@main (1.31x), with metadata-mirror reads dropping from 2625 to 1297. --------- Co-authored-by: Zoltan Kochan <[email protected]>
1 parent acbdb94 commit 11a7fdd

14 files changed

Lines changed: 696 additions & 77 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@pnpm/resolving.npm-resolver": patch
3+
"pnpm": patch
4+
---
5+
6+
Sped up offline and `--prefer-offline` resolution on large workspaces (e.g. `pnpm dedupe --offline`, `pnpm install --offline`). Package metadata loaded from the local cache is now kept in memory, so each package's metadata is parsed once per command instead of once per dependent that references it.

‎.github/workflows/benchmark.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ jobs:
8383

8484
- name: Run benchmarks
8585
id: bench
86-
continue-on-error: true
8786
run: |
8887
set -o pipefail
8988
./pnpm11/benchmarks/bench.sh 2>&1 | tee bench-output.txt

‎.github/workflows/pacquet-integrated-benchmark.yml‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,22 @@ jobs:
327327
cp bench-work-env/BENCHMARK_REPORT.md bench-work-env/BENCHMARK_REPORT_ISOLATED_FRESH_INSTALL_COLD_CACHE_HOT_STORE.md
328328
cp bench-work-env/BENCHMARK_REPORT.json bench-work-env/BENCHMARK_REPORT_ISOLATED_FRESH_INSTALL_COLD_CACHE_HOT_STORE.json
329329
330+
- name: 'Benchmark: Isolated linker: fresh resolve, hot cache, offline'
331+
shell: bash
332+
# Offline re-resolution from the warm on-disk packument mirror:
333+
# `install --offline --lockfile-only` with the lockfile removed per
334+
# iteration (an online pre-warm pass primes the mirror first). No
335+
# network and no linking, so the timed work is almost purely mirror
336+
# reads + packument parsing — the series that guards offline /
337+
# prefer-offline resolution, e.g. the disk-to-memory metadata
338+
# promotion of pnpm/pnpm#12760. Cheapest scenario per iteration, so
339+
# 15 min is ample.
340+
timeout-minutes: 15
341+
run: |
342+
just integrated-benchmark --reuse-prebuilt-binaries --scenario=isolated-linker.fresh-resolve.hot-cache.offline --registry=verdaccio --pnpr-latency-ms=${PNPR_LATENCY_MS} --registry-latency-ms=${REGISTRY_LATENCY_MS} --registry-bandwidth-mbps=${REGISTRY_BANDWIDTH_MBPS} $BENCHMARK_TARGETS
343+
cp bench-work-env/BENCHMARK_REPORT.md bench-work-env/BENCHMARK_REPORT_ISOLATED_FRESH_RESOLVE_HOT_CACHE_OFFLINE.md
344+
cp bench-work-env/BENCHMARK_REPORT.json bench-work-env/BENCHMARK_REPORT_ISOLATED_FRESH_RESOLVE_HOT_CACHE_OFFLINE.json
345+
330346
- name: 'Benchmark: Isolated linker: fresh restore, cold cache + cold store + cold pnpr'
331347
shell: bash
332348
# The only scenario with a cold pnpr-side cache: the per-revision mock
@@ -457,6 +473,18 @@ jobs:
457473
echo
458474
echo '</details>'
459475
echo
476+
echo '### Scenario: Isolated linker: fresh resolve, hot cache, offline'
477+
echo
478+
cat bench-work-env/BENCHMARK_REPORT_ISOLATED_FRESH_RESOLVE_HOT_CACHE_OFFLINE.md
479+
echo
480+
echo '<details><summary>BENCHMARK_REPORT.json</summary>'
481+
echo
482+
echo '```json'
483+
jq 'del(.results[].exit_codes)' bench-work-env/BENCHMARK_REPORT_ISOLATED_FRESH_RESOLVE_HOT_CACHE_OFFLINE.json
484+
echo '```'
485+
echo
486+
echo '</details>'
487+
echo
460488
echo '### Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr'
461489
echo
462490
cat bench-work-env/BENCHMARK_REPORT_ISOLATED_FRESH_RESTORE_COLD_CACHE_COLD_STORE_COLD_PNPR.md
@@ -475,7 +503,7 @@ jobs:
475503
# Bencher's shell_hyperfine adapter accepts, one per testbed. For
476504
# each, keep only the chosen target's result from each scenario
477505
# and rename `.command` to the scenario name, so Bencher names the
478-
# benchmark after the scenario. Both tools run all five scenarios,
506+
# benchmark after the scenario. Both tools run every scenario,
479507
# so the `pacquet` testbed gets `pacquet@HEAD` and the `pnpr`
480508
# testbed gets `pnpr@HEAD`, each across the same scenario set.
481509
shell: bash
@@ -507,6 +535,7 @@ jobs:
507535
'ISOLATED_FRESH_INSTALL_COLD_CACHE_COLD_STORE:isolated-linker.fresh-install.cold-cache.cold-store' \
508536
'ISOLATED_FRESH_INSTALL_HOT_CACHE_HOT_STORE:isolated-linker.fresh-install.hot-cache.hot-store' \
509537
'ISOLATED_FRESH_INSTALL_COLD_CACHE_HOT_STORE:isolated-linker.fresh-install.cold-cache.hot-store' \
538+
'ISOLATED_FRESH_RESOLVE_HOT_CACHE_OFFLINE:isolated-linker.fresh-resolve.hot-cache.offline' \
510539
'ISOLATED_FRESH_RESTORE_COLD_CACHE_COLD_STORE_COLD_PNPR:isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr'
511540
512541
build_bencher_file bench-work-env/bencher-results-pnpr.json pnpr@HEAD \
@@ -515,6 +544,7 @@ jobs:
515544
'ISOLATED_FRESH_INSTALL_COLD_CACHE_COLD_STORE:isolated-linker.fresh-install.cold-cache.cold-store' \
516545
'ISOLATED_FRESH_INSTALL_HOT_CACHE_HOT_STORE:isolated-linker.fresh-install.hot-cache.hot-store' \
517546
'ISOLATED_FRESH_INSTALL_COLD_CACHE_HOT_STORE:isolated-linker.fresh-install.cold-cache.hot-store' \
547+
'ISOLATED_FRESH_RESOLVE_HOT_CACHE_OFFLINE:isolated-linker.fresh-resolve.hot-cache.offline' \
518548
'ISOLATED_FRESH_RESTORE_COLD_CACHE_COLD_STORE_COLD_PNPR:isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr'
519549
520550
- name: Stage artifact contents

‎pacquet/crates/resolving-npm-resolver/src/create_npm_resolution_verifier.rs‎

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ impl NpmResolutionVerifier {
667667
};
668668
let value = cell
669669
.get_or_init(|| async {
670-
if let Some(shared) = self.read_shared_meta(name) {
670+
if let Some(shared) = self.read_shared_meta(registry, name) {
671671
return Ok(project_abbreviated_meta(&shared));
672672
}
673673
let opts = FetchFullMetadataCachedOptions {
@@ -694,15 +694,23 @@ impl NpmResolutionVerifier {
694694
}
695695

696696
/// Try the resolver's shared [`PackageMetaCache`] for a packument
697-
/// the abbreviated projection can derive from. Prefer the
698-
/// `name:full` entry: it's a strict superset of the abbreviated
699-
/// shape, so a hit there subsumes the bare `name` entry.
700-
fn read_shared_meta(&self, name: &PkgName) -> Option<Arc<Package>> {
697+
/// the abbreviated projection can derive from. The resolver keys
698+
/// entries by registry plus name (see `metadata_cache_key`), with a
699+
/// `:full` / `:full:filtered` suffix depending on its own metadata
700+
/// mode, so try full, filtered full, then abbreviated — a full form
701+
/// is a strict superset of the abbreviated shape, and `clear_meta`
702+
/// keeps every field the projection reads. Private-scoped entries
703+
/// carry a descriptor prefix the verifier can't reproduce; those
704+
/// simply miss and fall through to the verifier's own fetch chain.
705+
fn read_shared_meta(&self, registry: &str, name: &PkgName) -> Option<Arc<Package>> {
701706
let cache = self.meta_cache.as_ref()?;
702707
let name_str = name.to_string();
708+
let key = package_key(registry, &name_str);
703709
cache
704-
.get(&format!("{name_str}:full"))
705-
.or_else(|| cache.get(&name_str))
710+
.get(&format!("{key}:full"))
711+
.or_else(|| cache.get(&format!("{key}:full:filtered")))
712+
.or_else(|| cache.get(&key))
713+
.map(|cached| cached.meta)
706714
.filter(|meta| meta.name == name_str)
707715
}
708716

@@ -804,16 +812,21 @@ impl NpmResolutionVerifier {
804812
};
805813
cell.get_or_init(|| async {
806814
// Fast path: if the resolver already pulled the full packument
807-
// during the same install (`{registry}\x00{name}:full` key in
808-
// the shared metaCache, populated when `pick_package` upgrades
809-
// for `minimumReleaseAge`), reuse it. Abbreviated entries are
810-
// rejected here — `fail_if_trust_downgraded` needs per-version
811-
// `time` and per-version trust evidence, both of which only
812-
// the full form carries.
813-
let shared =
814-
self.meta_cache.as_ref().and_then(|cache| cache.get(&format!("{key}:full")));
815-
if let Some(meta) = shared {
816-
return Ok(Arc::new(project_trust_meta(meta.as_ref())));
815+
// during the same install (`{registry}\x00{name}:full` or
816+
// `...:full:filtered` key in the shared metaCache, populated
817+
// when `pick_package` upgrades for `minimumReleaseAge`),
818+
// reuse it. The filtered form is accepted: `clear_meta`
819+
// keeps `time`, per-version `_npmUser`, and `dist`, which is
820+
// everything `fail_if_trust_downgraded` reads. Abbreviated
821+
// entries are rejected — they lack per-version `time` and
822+
// trust evidence.
823+
let shared = self.meta_cache.as_ref().and_then(|cache| {
824+
cache
825+
.get(&format!("{key}:full"))
826+
.or_else(|| cache.get(&format!("{key}:full:filtered")))
827+
});
828+
if let Some(cached) = shared {
829+
return Ok(Arc::new(project_trust_meta(cached.meta.as_ref())));
817830
}
818831
// Project the packument to just the fields `fail_if_trust_downgraded`
819832
// reads before stashing in the cache. The full document — dependency

‎pacquet/crates/resolving-npm-resolver/src/lib.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ pub use parse_bare_specifier::{
6060
parse_named_registry_specifier_to_registry_package_spec,
6161
};
6262
pub use pick_package::{
63-
InMemoryPackageMetaCache, MirrorPersistError, PackageMetaCache, PackumentFetchLocker,
64-
PickPackageContext, PickPackageError, PickPackageOptions, PickPackageResult,
65-
PickedManifestCache, persist_meta_to_mirror, pick_package, shared_in_memory_cache,
66-
shared_packument_fetch_locker, shared_picked_manifest_cache,
63+
CachedPackument, InMemoryPackageMetaCache, MirrorPersistError, PackageMetaCache,
64+
PackumentFetchLocker, PickPackageContext, PickPackageError, PickPackageOptions,
65+
PickPackageResult, PickedManifestCache, persist_meta_to_mirror, pick_package,
66+
shared_in_memory_cache, shared_packument_fetch_locker, shared_picked_manifest_cache,
6767
};
6868
pub use pick_package_from_meta::{
6969
PickPackageFromMetaError, PickPackageFromMetaOptions, PickVersionByVersionRangeOptions,

‎pacquet/crates/resolving-npm-resolver/src/pick_package.rs‎

Lines changed: 84 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ use crate::{
7676
registry_url::to_registry_url,
7777
};
7878

79+
/// A cached packument together with its registry-verification state.
80+
/// The two travel as one value so a reader can never pair a packument
81+
/// with the verification state of a concurrent overwrite.
82+
#[derive(Debug, Clone)]
83+
pub struct CachedPackument {
84+
pub meta: Arc<Package>,
85+
/// `false` when the packument was parsed straight from the
86+
/// on-disk mirror without a validating registry round-trip (see
87+
/// [`PackageMetaCache::set_unverified`]).
88+
pub registry_verified: bool,
89+
}
90+
7991
/// In-memory packument cache the orchestrator consults before any
8092
/// disk read. A thin map abstraction so a long-lived install can
8193
/// share one cache across many [`pick_package`] calls.
@@ -86,12 +98,12 @@ use crate::{
8698
/// contention shows up in benchmarks.
8799
pub trait PackageMetaCache: Send + Sync {
88100
/// Shared handle to the cached packument for `key`, or `None`
89-
/// when the cache hasn't seen it. Returned as
101+
/// when the cache hasn't seen it. The packument is carried as
90102
/// [`Arc<Package>`] so cross-resolve sharing of a popular
91103
/// packument (`react`, `lodash`, ...) doesn't deep-clone the
92104
/// full versions map on every consumer's hit. Returns shared
93105
/// references, not copies.
94-
fn get(&self, key: &str) -> Option<Arc<Package>>;
106+
fn get(&self, key: &str) -> Option<CachedPackument>;
95107
/// Insert/overwrite `meta` under `key`. The orchestrator inserts
96108
/// after a fresh fetch and after any disk-fast-path that returns
97109
/// successfully — populating the cache from the disk read avoids
@@ -102,7 +114,27 @@ pub trait PackageMetaCache: Send + Sync {
102114
/// accepted; the next install starts a fresh cache. Takes
103115
/// [`Arc<Package>`] so callers can share the same handle they
104116
/// hand back to [`PickPackageResult`] without an extra clone.
117+
///
118+
/// The caller vouches that `meta` came from (or was revalidated
119+
/// by) the registry: the entry replaces any registry-unverified
120+
/// one a previous [`PackageMetaCache::set_unverified`] stored
121+
/// under `key`.
105122
fn set(&self, key: String, meta: Arc<Package>);
123+
124+
/// Like [`PackageMetaCache::set`], but stores the entry as
125+
/// registry-unverified: it was parsed straight from the on-disk
126+
/// mirror without a validating registry round-trip, so it may
127+
/// predate versions the registry has. [`pick_package`] uses the
128+
/// state to fall through to a conditional registry request —
129+
/// instead of failing the pick — when a cache hit on such an entry
130+
/// can't satisfy the requested spec and the resolver isn't offline.
131+
/// The verified [`PackageMetaCache::set`] the fetch then performs
132+
/// replaces the entry, so each package revalidates at most once.
133+
///
134+
/// Required (no default) on purpose: an implementation that stored
135+
/// these entries as verified would silently turn a recoverable
136+
/// stale-mirror miss into a terminal "no matching version".
137+
fn set_unverified(&self, key: String, meta: Arc<Package>);
106138
}
107139

108140
/// Per-`(registry, package_name)` fetch serializer: a map of
@@ -172,16 +204,20 @@ pub fn shared_picked_manifest_cache() -> PickedManifestCache {
172204
/// top contention point of a warm-resolve time profile.
173205
#[derive(Debug, Default)]
174206
pub struct InMemoryPackageMetaCache {
175-
inner: DashMap<String, Arc<Package>>,
207+
inner: DashMap<String, CachedPackument>,
176208
}
177209

178210
impl PackageMetaCache for InMemoryPackageMetaCache {
179-
fn get(&self, key: &str) -> Option<Arc<Package>> {
180-
self.inner.get(key).map(|entry| Arc::clone(entry.value()))
211+
fn get(&self, key: &str) -> Option<CachedPackument> {
212+
self.inner.get(key).map(|entry| entry.value().clone())
181213
}
182214

183215
fn set(&self, key: String, meta: Arc<Package>) {
184-
self.inner.insert(key, meta);
216+
self.inner.insert(key, CachedPackument { meta, registry_verified: true });
217+
}
218+
219+
fn set_unverified(&self, key: String, meta: Arc<Package>) {
220+
self.inner.insert(key, CachedPackument { meta, registry_verified: false });
185221
}
186222
}
187223

@@ -428,8 +464,9 @@ pub async fn pick_package<Cache: PackageMetaCache>(
428464
let use_mem_cache = !opts.update_checksums;
429465

430466
// 1. In-memory cache.
431-
if use_mem_cache && let Some(cached) = ctx.meta_cache.get(&cache_key) {
432-
return handle_cache_hit(
467+
if use_mem_cache
468+
&& let Some(cached) = ctx.meta_cache.get(&cache_key)
469+
&& let Some(result) = handle_cache_hit(
433470
ctx,
434471
spec,
435472
opts,
@@ -440,7 +477,9 @@ pub async fn pick_package<Cache: PackageMetaCache>(
440477
pkg_mirror.as_deref(),
441478
cached,
442479
)
443-
.await;
480+
.await?
481+
{
482+
return Ok(result);
444483
}
445484

446485
let limit = {
@@ -457,8 +496,9 @@ pub async fn pick_package<Cache: PackageMetaCache>(
457496
// this re-check, every duplicate caller would still fall
458497
// through to the disk + network path even though they were
459498
// waiting precisely for the winner's fetch to complete.
460-
if use_mem_cache && let Some(cached) = ctx.meta_cache.get(&cache_key) {
461-
return handle_cache_hit(
499+
if use_mem_cache
500+
&& let Some(cached) = ctx.meta_cache.get(&cache_key)
501+
&& let Some(result) = handle_cache_hit(
462502
ctx,
463503
spec,
464504
opts,
@@ -469,7 +509,9 @@ pub async fn pick_package<Cache: PackageMetaCache>(
469509
pkg_mirror.as_deref(),
470510
cached,
471511
)
472-
.await;
512+
.await?
513+
{
514+
return Ok(result);
473515
}
474516

475517
let mut meta_cached_in_store: Option<Arc<Package>> = None;
@@ -480,6 +522,12 @@ pub async fn pick_package<Cache: PackageMetaCache>(
480522

481523
if ctx.offline {
482524
if let Some(meta) = meta_cached_in_store {
525+
// maybe_upgrade_abbreviated_meta_for_release_age
526+
// short-circuits when offline, so a later cache hit
527+
// returns this same meta without any network access.
528+
if !opts.dry_run {
529+
ctx.meta_cache.set_unverified(cache_key.clone(), Arc::clone(&meta));
530+
}
483531
let (meta, picked) =
484532
pick_from_meta(&picker_opts, spec, meta, opts.blocked_versions)?;
485533
return Ok(PickPackageResult { meta, picked_package: picked });
@@ -510,6 +558,14 @@ pub async fn pick_package<Cache: PackageMetaCache>(
510558
let (picked_meta, picked) =
511559
pick_from_meta(&picker_opts, spec, Arc::clone(&meta), opts.blocked_versions)?;
512560
if picked.is_some() {
561+
// A cache hit re-runs the release-age upgrade check, so
562+
// serving this meta from memory can't bypass the upgrade.
563+
// The upgrade branch above already cached the registry-
564+
// validated document; don't downgrade it to an unverified
565+
// marking.
566+
if !upgrade.upgraded && !opts.dry_run {
567+
ctx.meta_cache.set_unverified(cache_key.clone(), Arc::clone(&meta));
568+
}
513569
return Ok(PickPackageResult { meta: picked_meta, picked_package: picked });
514570
}
515571
// Fall through to fetch when disk had the meta but no
@@ -552,7 +608,7 @@ pub async fn pick_package<Cache: PackageMetaCache>(
552608
// the next install starts a fresh cache and
553609
// re-evaluates the disk shortcut.
554610
if !opts.dry_run {
555-
ctx.meta_cache.set(cache_key.clone(), Arc::clone(meta));
611+
ctx.meta_cache.set_unverified(cache_key.clone(), Arc::clone(meta));
556612
}
557613
return Ok(PickPackageResult { meta: picked_meta, picked_package: Some(picked) });
558614
}
@@ -677,6 +733,12 @@ pub async fn pick_package<Cache: PackageMetaCache>(
677733
/// re-fetching). Extracting it keeps the two call sites identical so
678734
/// the upgrade-and-persist side-effects can't drift.
679735
///
736+
/// Returns `Ok(None)` when the hit must not be terminal: the entry is
737+
/// a registry-unverified disk promotion (see
738+
/// [`PackageMetaCache::set_unverified`]) whose pick failed, and the
739+
/// resolver isn't offline. The caller then falls through to the disk +
740+
/// network flow, whose fetch replaces the entry with a verified one.
741+
///
680742
/// The argument list is wide because the helper consumes everything
681743
/// the per-call frame already computed (cache key, derived
682744
/// `full_metadata`, pre-resolved mirror path, picker options).
@@ -696,20 +758,25 @@ async fn handle_cache_hit<Cache: PackageMetaCache>(
696758
use_filtered_full_metadata: bool,
697759
cache_key: &str,
698760
pkg_mirror: Option<&Path>,
699-
cached: Arc<Package>,
700-
) -> Result<PickPackageResult, PickPackageError> {
761+
cached: CachedPackument,
762+
) -> Result<Option<PickPackageResult>, PickPackageError> {
701763
let upgrade =
702-
maybe_upgrade_abbreviated_meta_for_release_age(ctx, spec, opts, full_metadata, cached)
764+
maybe_upgrade_abbreviated_meta_for_release_age(ctx, spec, opts, full_metadata, cached.meta)
703765
.await?;
704766
let meta = upgrade.meta;
767+
// The upgrade fetch (re)validated the packument against the registry.
768+
let registry_verified = cached.registry_verified || upgrade.upgraded;
705769
if upgrade.upgraded && !opts.dry_run {
706770
if let Some(path) = pkg_mirror {
707771
persist_upgraded_to_mirror(path, &meta, use_filtered_full_metadata);
708772
}
709773
ctx.meta_cache.set(cache_key.to_string(), Arc::clone(&meta));
710774
}
711775
let (meta, picked) = pick_from_meta(picker_opts, spec, meta, opts.blocked_versions)?;
712-
Ok(PickPackageResult { meta, picked_package: picked })
776+
if picked.is_none() && !ctx.offline && !registry_verified {
777+
return Ok(None);
778+
}
779+
Ok(Some(PickPackageResult { meta, picked_package: picked }))
713780
}
714781

715782
/// Same fields as [`PickPackageOptions`] minus the dispatcher-only

0 commit comments

Comments
 (0)