Repository navigation
fix: reject frozen install when an injected package's dependencies drift with separate lockfiles - #17022
fix: reject frozen install when an injected package's dependencies drift with separate lockfiles#17022neonsid wants to merge 1 commit into
Conversation
…ift with separate lockfiles With `sharedWorkspaceLockfile: false`, a frozen install of a project that injects a workspace package never compared that package's own dependencies with its snapshot in the project's lockfile. The frozen check passed `skipLocalDirectoryDependencies`, and with separate lockfiles the injected package is not an importer of the same lockfile, so nothing else caught the drift. `--frozen-lockfile` exited 0 and installed the old resolutions. The nested comparison now runs for injected `workspace:` dependencies on the frozen path too. Plain `file:` directory dependencies are still skipped, which keeps deploy lockfiles (absolute `file://` refs) passing. A frozen install fails on a stale verdict, so the comparison had to stop reporting unchanged lockfiles as stale: - It applies the install's readPackage hook (overrides, package extensions, pnpmfile hooks) to the manifest before comparing, since the snapshot records the hooked manifest. - It resolves `catalog:` specs through the configured catalogs. - It accepts the resolved peers the snapshot records among the dependencies, compares peer ranges as ranges, and treats a dependency also declared as a peer the way the resolver does: as a peer when the lockfile records it among the peers, as an own dependency otherwise. These rules match the v12 freshness check, which already rejects this case. Closes pnpm#17008 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Same-run regression checkHEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval. Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.
Integrated-Benchmark Report (Linux)Commit: Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked and injected workspace scenarios compare current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.44545746318,
"stddev": 0.12720908452352472,
"median": 2.49535919408,
"user": 1.4534717799999999,
"system": 1.3732607799999998,
"min": 2.25331847858,
"max": 2.57915875958
},
{
"command": "pacquet@main",
"mean": 2.40039727528,
"stddev": 0.15754449406356255,
"median": 2.32819293858,
"user": 1.34709818,
"system": 1.3102115800000003,
"min": 2.24668958258,
"max": 2.61580835058
},
{
"command": "pnpr@HEAD",
"mean": 1.4147089154799999,
"stddev": 0.1425367508637405,
"median": 1.33988223058,
"user": 1.2371434799999999,
"system": 1.1402876800000001,
"min": 1.2962249885800001,
"max": 1.65854135458
},
{
"command": "pnpr@main",
"mean": 1.4212694495800002,
"stddev": 0.09489441714330288,
"median": 1.39575178208,
"user": 1.2587190799999999,
"system": 1.1520195800000002,
"min": 1.29713351858,
"max": 1.5696519745800002
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2290561667,
"stddev": 0.007990425279309786,
"median": 0.2265537787,
"user": 0.24545692,
"system": 0.5730318999999999,
"min": 0.21698891420000002,
"max": 0.2396669042
},
{
"command": "pacquet@main",
"mean": 0.23304011070000002,
"stddev": 0.029954947026694562,
"median": 0.2240656197,
"user": 0.27087392,
"system": 0.5659597,
"min": 0.2057007992,
"max": 0.31090672620000004
},
{
"command": "pnpr@HEAD",
"mean": 0.3116344832,
"stddev": 0.08442127007241855,
"median": 0.28939383020000004,
"user": 0.36034521999999997,
"system": 0.7170202000000001,
"min": 0.2255081132,
"max": 0.4239213352
},
{
"command": "pnpr@main",
"mean": 0.23971466350000004,
"stddev": 0.012132941947687695,
"median": 0.23864317570000002,
"user": 0.27031602,
"system": 0.553635,
"min": 0.22394537720000002,
"max": 0.26529941120000006
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.007760439470310553,
"stddev": 0.00045868818905374023,
"median": 0.00769872302,
"user": 0.004547783105590064,
"system": 0.003899727577639751,
"min": 0.00695773452,
"max": 0.011248235520000002
},
{
"command": "pacquet@main",
"mean": 0.007611456177575758,
"stddev": 0.0003815944053869278,
"median": 0.00757792552,
"user": 0.0044148890909090875,
"system": 0.0038214661818181785,
"min": 0.00687164152,
"max": 0.00994466352
},
{
"command": "pnpr@HEAD",
"mean": 0.008550716116385538,
"stddev": 0.0016852532300126078,
"median": 0.008034354520000002,
"user": 0.005415075180722892,
"system": 0.003986177228915663,
"min": 0.00696793252,
"max": 0.017715311520000002
},
{
"command": "pnpr@main",
"mean": 0.014975754681676645,
"stddev": 0.0020111965807160267,
"median": 0.015217642520000001,
"user": 0.008222444670658684,
"system": 0.00800884766467066,
"min": 0.00954925952,
"max": 0.01963422152
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.008843041749285713,
"stddev": 0.0004926250400323346,
"median": 0.008797390660000001,
"user": 0.005606981428571429,
"system": 0.0040889005714285715,
"min": 0.00779528216,
"max": 0.010666986160000001
},
{
"command": "pacquet@main",
"mean": 0.008736512487272722,
"stddev": 0.0004835472966610544,
"median": 0.008660668160000001,
"user": 0.005269400000000005,
"system": 0.004269635054545456,
"min": 0.00778471216,
"max": 0.01057982216
},
{
"command": "pnpr@HEAD",
"mean": 0.008761901932727278,
"stddev": 0.0005453910142672586,
"median": 0.008721807160000001,
"user": 0.005617244848484849,
"system": 0.00397798106060606,
"min": 0.00745651516,
"max": 0.01143949816
},
{
"command": "pnpr@main",
"mean": 0.00877718013222223,
"stddev": 0.0004728598579807814,
"median": 0.00872847516,
"user": 0.005329271904761906,
"system": 0.004212912539682542,
"min": 0.007942338160000001,
"max": 0.01105655816
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.4944210887800002,
"stddev": 0.07650916881371882,
"median": 2.46806420918,
"user": 1.79975472,
"system": 1.5900822799999998,
"min": 2.43764813718,
"max": 2.69787154618
},
{
"command": "pacquet@main",
"mean": 2.46672283908,
"stddev": 0.014384124142033421,
"median": 2.46698735818,
"user": 1.7013037199999999,
"system": 1.4477577799999999,
"min": 2.43859850918,
"max": 2.48688705218
},
{
"command": "pnpr@HEAD",
"mean": 1.4851214671800002,
"stddev": 0.10187529944397235,
"median": 1.4369523446799999,
"user": 1.12350322,
"system": 1.21895058,
"min": 1.3843098481799998,
"max": 1.68178195018
},
{
"command": "pnpr@main",
"mean": 1.5026245011800001,
"stddev": 0.11353117658073687,
"median": 1.47878881268,
"user": 1.0919514199999998,
"system": 1.1926174800000002,
"min": 1.38724008018,
"max": 1.70211295718
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.44126407294000003,
"stddev": 0.02126316986876709,
"median": 0.43713193594000005,
"user": 0.60109072,
"system": 0.77575018,
"min": 0.40692918144,
"max": 0.47659292944000003
},
{
"command": "pacquet@main",
"mean": 0.43960971043999997,
"stddev": 0.012489989969306033,
"median": 0.43952141994000005,
"user": 0.6194141199999998,
"system": 0.77382778,
"min": 0.42212628644000005,
"max": 0.46300160344
},
{
"command": "pnpr@HEAD",
"mean": 0.28007966654000005,
"stddev": 0.015664482645410465,
"median": 0.27583830844,
"user": 0.23546472000000002,
"system": 0.52184838,
"min": 0.26575461444000004,
"max": 0.31945368444
},
{
"command": "pnpr@main",
"mean": 0.28847715374000005,
"stddev": 0.005782844336580527,
"median": 0.28707161994,
"user": 0.23525512,
"system": 0.58251758,
"min": 0.28136350744,
"max": 0.29768627344000004
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.7151327286399998,
"stddev": 0.008828531746585036,
"median": 1.7155220174399999,
"user": 1.10879328,
"system": 1.2310626,
"min": 1.70323158344,
"max": 1.7337791134399998
},
{
"command": "pacquet@main",
"mean": 1.7769944525399997,
"stddev": 0.14940419212885975,
"median": 1.71075212594,
"user": 1.2410044800000002,
"system": 1.3582524999999999,
"min": 1.6887078844399999,
"max": 2.14460939644
},
{
"command": "pnpr@HEAD",
"mean": 0.3667957566400001,
"stddev": 0.006083573069932814,
"median": 0.36715861644000003,
"user": 0.33854267999999993,
"system": 0.7794867000000001,
"min": 0.35811411044,
"max": 0.37966593144000005
},
{
"command": "pnpr@main",
"mean": 0.36340297713999997,
"stddev": 0.007497067632356662,
"median": 0.36611529394000003,
"user": 0.32319028000000005,
"system": 0.8004614,
"min": 0.34903955744000004,
"max": 0.37100723744
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.28023973636000005,
"stddev": 0.01726416093069734,
"median": 0.28155685286,
"user": 0.25703087999999996,
"system": 0.1239136,
"min": 0.25622431886,
"max": 0.30951218086000004
},
{
"command": "pacquet@main",
"mean": 0.27905913496,
"stddev": 0.01653416004609968,
"median": 0.27596392236,
"user": 0.26213748,
"system": 0.11773309999999997,
"min": 0.25047465686000003,
"max": 0.30485270286000005
},
{
"command": "pnpr@HEAD",
"mean": 0.09980590882296297,
"stddev": 0.002544518490715974,
"median": 0.10011831686,
"user": 0.044544005925925924,
"system": 0.01856774814814815,
"min": 0.09467971686,
"max": 0.10452088586
},
{
"command": "pnpr@main",
"mean": 0.09901220125285712,
"stddev": 0.002271405395941584,
"median": 0.09927112536,
"user": 0.045117687142857146,
"system": 0.01645145714285714,
"min": 0.09502984786,
"max": 0.10291250286
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.24324989862222215,
"stddev": 0.044755904582628236,
"median": 0.2199393714,
"user": 0.23846208444444444,
"system": 0.06126202222222221,
"min": 0.2054178704,
"max": 0.3232889304
},
{
"command": "pacquet@main",
"mean": 0.21314774706666667,
"stddev": 0.005161066998013231,
"median": 0.2121847654,
"user": 0.2172794177777778,
"system": 0.05185779999999999,
"min": 0.2071038254,
"max": 0.2233837794
},
{
"command": "pnpm@HEAD",
"mean": 3.4588399236222225,
"stddev": 0.11108017387702626,
"median": 3.4120405074,
"user": 4.950703528888888,
"system": 0.42564791111111105,
"min": 3.3683712214,
"max": 3.6904858724
}
]
}Scenario: Isolated linker: linked-workspace resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.19613815896000003,
"stddev": 0.004857908098476561,
"median": 0.19702777816000003,
"user": 0.14969875333333335,
"system": 0.08255418666666667,
"min": 0.18915703916,
"max": 0.20925883616000002
},
{
"command": "pacquet@main",
"mean": 0.19944468030285714,
"stddev": 0.005212571871559815,
"median": 0.19917125866000002,
"user": 0.1615854771428571,
"system": 0.07597237714285714,
"min": 0.19133487416000003,
"max": 0.20827473616000003
}
]
}Scenario: Isolated linker: injected workspace repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.07935263369621626,
"stddev": 0.0035114114214724193,
"median": 0.07858564748,
"user": 0.03036470054054054,
"system": 0.05444620648648649,
"min": 0.07333242948,
"max": 0.09190061248
},
{
"command": "pacquet@main",
"mean": 0.07459361745435898,
"stddev": 0.0027360849052248523,
"median": 0.07374804048000001,
"user": 0.02648913435897435,
"system": 0.05335815589743588,
"min": 0.07066116648000001,
"max": 0.08169947148000001
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.4862935262,
"stddev": 0.1468357845086953,
"median": 4.400650902100001,
"user": 1.3860151399999998,
"system": 1.4915818599999997,
"min": 4.3569669166,
"max": 4.7555697256
},
{
"command": "pacquet@main",
"mean": 4.4110205132,
"stddev": 0.08506023981330732,
"median": 4.3782487856,
"user": 1.41189484,
"system": 1.4192768599999999,
"min": 4.3223663636,
"max": 4.5729821176
},
{
"command": "pnpr@HEAD",
"mean": 3.4832535471,
"stddev": 0.11027296211862787,
"median": 3.4576667410999997,
"user": 1.3098903399999997,
"system": 1.3415785599999999,
"min": 3.4030139926,
"max": 3.7734724566
},
{
"command": "pnpr@main",
"mean": 3.5547921064000008,
"stddev": 0.1255605063426064,
"median": 3.5096097861,
"user": 1.35790364,
"system": 1.31231076,
"min": 3.3990059966,
"max": 3.7488557096
}
]
}Scenario: GVS linker: fresh restore, hot cache + hot storeSame install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.11934286354545458,
"stddev": 0.0031555904836230325,
"median": 0.11931897350000001,
"user": 0.1436989090909091,
"system": 0.1266067527272727,
"min": 0.11417511600000001,
"max": 0.12610164299999999
},
{
"command": "pacquet@main",
"mean": 0.11882618176190476,
"stddev": 0.0027488100035890617,
"median": 0.11924944200000001,
"user": 0.15002019047619047,
"system": 0.11633486095238095,
"min": 0.11275431300000001,
"max": 0.12320300000000001
},
{
"command": "pnpr@HEAD",
"mean": 0.12878752685,
"stddev": 0.003114957786958701,
"median": 0.1287085475,
"user": 0.14551184999999997,
"system": 0.13548313,
"min": 0.12375261400000001,
"max": 0.135700401
},
{
"command": "pnpr@main",
"mean": 0.13184447789473683,
"stddev": 0.0035132915693928853,
"median": 0.132379515,
"user": 0.157591947368421,
"system": 0.13021174315789472,
"min": 0.125884084,
"max": 0.137499978
}
]
}Scenario: Store only: unlocked direct deps, cold cache + hot storeStore-only install (
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.1167739732999997,
"stddev": 0.02684100084234003,
"median": 1.1206425624,
"user": 0.4883243799999999,
"system": 0.21075964000000003,
"min": 1.0607493204,
"max": 1.1581078734
},
{
"command": "pacquet@main",
"mean": 1.1180693822999999,
"stddev": 0.021392302329141744,
"median": 1.1178268184,
"user": 0.50330138,
"system": 0.18510654,
"min": 1.0826317864,
"max": 1.1459452274
}
]
} |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
zkochan
left a comment
There was a problem hiding this comment.
Thanks for this. The approach is the one we want for #17008 for now: pnpm/tasks#145 leaves the "record the declared specs in the lockfile" redesign for later.
The comparison now runs on the frozen path, and in its current form it rejects lockfiles that pnpm 11.28.6 just wrote. pnpm 12.13.0 accepts each of these lockfiles under --frozen-lockfile, but this branch fails with ERR_PNPM_OUTDATED_LOCKFILE. CI users would hit that directly. It is not limited to sharedWorkspaceLockfile: false: a shared lockfile reaches the same code whenever an injected package stays file: instead of being deduped to link:, which is the usual case for an injected package with peers.
I checked these by running the PR's verification sources against real 11.28.6 lockfiles. I did not run the bundle.
- Non-range specs always look outdated (
localDirectoryDepIsUpToDate.ts, thesemver.satisfiesbranch, now reached throughlinkedPackagesAreUpToDate.ts). Take an injected package that declares"is-positive": "latest". pnpm 11 records3.1.0, andsatisfies('3.1.0', 'latest')is false. Git, tarball,jsr:andnpm:b@latestspecs fail the same way. v12 accepts any spec that is not a valid range and checks only the alias name forname@versionrefs (npm_or_registry_spec_satisfiesinpnpm/crates/package-manager/src/install/lockfile_freshness/directory_deps/spec.rs). - Optional peers declared only in
peerDependenciesMetaalways look outdated. The v11 resolver records them aspeerDependencies: {name: '*'}(markOptionalPeers).getPeersResolvedAsPeersreads onlymanifest.peerDependencies, so the peer sets differ. When one of these peers resolves, it lands in the snapshot'soptionalDependenciesand fails the key check too. v12 adds these names as'*'(optional_peer_namesindirectory_deps/peers.rs). - A dependency that is also an optional peer always looks outdated. With
dependencies: {is-number: ^6},peerDependencies: {is-number: *}andpeerDependenciesMeta: {is-number: {optional: true}}, the resolver treatsis-numberas an own dependency and writes no peer meta.peerDependenciesMetaMatchstill compares the manifest meta. Compare it only for names in the resolved-as-peer set, as v12 does. - An optional dependency that never resolved fails every frozen install. With
optionalDependencies: {is-positive: ^99.0.0}, pnpm 11 writesfoo@file:foo: {}, and the check requires every manifest optional dependency to be in the snapshot. Importers already allow this on frozen installs (allowUnresolvedOptionalDependencies: frozenLockfileinverifyFrozenLockfile.ts), and so does v12. - The readPackage hook gets a directory the resolver does not pass.
ctx.readPackageHook(clone(manifest), localDepDir)selects the project hook set increateReadPackageHook, which leaves out the@yarnpkg/extensionscompatibility extensions. The resolver callsctx.readPackageHook(pkg)(resolveDependency.ts). Dropping the second argument keeps the two in step. - Smaller:
workspace:../foois still skipped. The new comparison is gated onisWorkspaceRangeSpec, so an injectedworkspace:<path>spec stays underskipLocalDirectoryDependenciesand keeps the bug. The comment saying injected workspace packages are always compared overstates this. Gate on whether the dependency is injected, or correct the comment.
Unit fixtures copied from real 11.28.6 lockfile output, one per shape above, would pin these. The current unit tests cover only shapes that already passed before this change.
Written by an agent (Claude Code, claude-opus-5-5).
|
One more case for the frozen path. An injected workspace package that publishes from pnpm v12 has this bug today. #17042 fixes it there by keying each project's manifest by its publish directory too. The same keying in v11's Written by an agent (Claude Code, claude-opus-5-5). |
|
Thanks for this, @neonsid. Your analysis of where the frozen check skips injected packages, and of the false "outdated" verdicts that come up once it stops skipping, shaped #17065. #17065 fixes the same issue a different way.
This is what v12 now does after #17053 and #17062. Because the rules match, the frozen install runs the check for every local directory dependency, including plain Since the two PRs fix the same issue, would you be OK with closing this one in favor of #17065? If you see a case your PR covers that 17065 misses, please point it out and I'll add it. Written by an agent (Claude Code, claude-opus-5-5). |
Summary
With
sharedWorkspaceLockfile: false,pnpm install --frozen-lockfileaccepted a lockfile whose snapshot of an injected workspace package no longer matched that package's dependencies. It exited 0 and installed the old resolutions. With a shared lockfile the injected package is also an importer and its own check catches the drift. With separate lockfiles nothing did, because the frozen check passesskipLocalDirectoryDependencies.The frozen path now compares the dependencies of injected
workspace:dependencies with their snapshot. Plainfile:directory dependencies stay skipped, so deploy lockfiles (absolutefile://refs) are unaffected.Turning the comparison on in frozen mode exposed false "outdated" verdicts on unchanged lockfiles. These cost only a re-resolve on the non-frozen path, but they would fail CI under
--frozen-lockfile.localDirectoryDepIsUpToDatenow:catalog:specs,This is a v11-only bug. pnpm 12.14.0 already rejects the case, and its freshness check (
lockfile_freshness/directory_deps) is the model for the rules above. I ran the same 16 workspace scenarios against this build and 12.14.0 (catalogs, named catalogs, overrides, packageExtensions, peers, dependency+peer, optional peers, optional deps, devDeps, shared lockfile,autoInstallPeers: false). Both accept the unchanged lockfile and reject the changed one in every scenario.One side effect: pnpmfile
readPackagehooks now also run on injected workspace manifests during the up-to-date check.Closes #17008
Squash Commit Body
Checklist
already linked to it solves it.
are implemented in every affected version.
pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
🤖 Generated with Claude Code
Written by an agent (Claude Code, claude-opus-5-5).
Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit
pnpm install --frozen-lockfilenow reportsERR_PNPM_OUTDATED_LOCKFILEwhen dependencies of an injected workspace package change while separate workspace lockfiles are enabled, instead of succeeding with an outdated resolution.