Repository navigation
perf: let projects with a pnpmfile use the fast lockfile updates - #13770
Conversation
The blanket readPackage gate on canTryFastUpdateLockfile predates the machinery that makes it unnecessary: getContext applies the composed readPackage hook to every project manifest, so drift detection and the handlers compare hooked manifests against the hooked state the lockfile records, and a changed pnpmfile surfaces as pnpmfileChecksum drift, which is not composable and falls back to the resolver. The freshness gates that validate every candidate are the same ones that already admit frozen-like installs for pnpmfile projects. pacquet has no such gate and already behaved this way; it gains the regression e2e tests, including one pinning that a fast update never rewrites a specifier a project-rewriting hook recorded. Writing that test surfaced a pre-existing recording divergence between the stacks, filed as #13769. Item 7 of #13696.
📝 WalkthroughWalkthroughFast lockfile updates now permit unchanged, checksum-covered pnpmfiles with Changespnpmfile Fast Update
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant requireHooks
participant depsInstaller
participant pnpmfileChecksum
participant lockfile
participant storeController
requireHooks->>depsInstaller: Provide hook tracking metadata
depsInstaller->>pnpmfileChecksum: Validate pnpmfile checksum coverage
pnpmfileChecksum-->>depsInstaller: Allow or reject fast update
depsInstaller->>lockfile: Remove dependency and preserve hook data
depsInstaller->>storeController: Avoid requests for eligible fast updates
Possibly related issues
Possibly related PRs
Suggested labels: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoEnable fast lockfile updates for projects using pnpmfile readPackage
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Confidence Score: 4/5The PR is not yet safe to merge because a pnpmfile composed with a programmatic readPackage hook can still take the fast path and retain a stale dependency graph. The fix tracks checksum-excluded pnpmfile hooks, but recursive hook composition appends programmatic hooks without setting the untracked flag, so the pnpmfile checksum can incorrectly vouch for the combined hook array. Files Needing Attention: pnpm11/installing/commands/src/recursive.ts, pnpm11/hooks/pnpmfile/src/requireHooks.ts, pnpm11/installing/deps-installer/src/install/index.ts Reviews (4): Last reviewed commit: "chore: sync tsconfig references via meta..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.changeset/pnpmfile-fast-update-gate.md:
- Around line 2-3: Add a "pacquet": patch entry to the changeset alongside the
existing package entries, ensuring both affected published packages receive
release bumps and release notes.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: cae909f3-c540-49fd-9b52-a04b82d4dde1
📒 Files selected for processing (5)
.changeset/pnpmfile-fast-update-gate.mdpnpm/crates/cli/tests/suite/lockfile_resolution_reuse.rspnpm11/installing/deps-installer/src/install/index.tspnpm11/installing/deps-installer/test/install/pnpmfileFastUpdate.tspnpm11/pnpm/test/install/lifecycleScripts.ts
Micro-Benchmark ResultsLinux |
Code Review by Qodo
1. Untracked hook fast-path
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13770 +/- ##
=======================================
Coverage 88.13% 88.14%
=======================================
Files 623 623
Lines 101380 101380
=======================================
+ Hits 89353 89361 +8
+ Misses 12027 12019 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The lifted gate relied on pnpmfileChecksum drift to catch a changed hook, but a hook passed programmatically (no pnpmfile behind it) has no checksum proving it unchanged between installs, so its output drift would go unnoticed by every freshness gate. The fast paths now admit readPackage hooks only when hooks.calculatePnpmfileChecksum is present, which requireHooks sets whenever the hooks come from real pnpmfiles. API consumers passing bare hooks keep today's full-resolution behavior, pinned by a test.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm11/installing/deps-installer/test/install/pnpmfileFastUpdate.ts (1)
115-121: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAdd checksum-drift coverage if no existing test covers it.
calculatePnpmfileChecksumalways returnstest-pnpmfile-checksumin these cases. The added tests verify unchanged pnpmfiles and hooks without checksum support, but they do not verify that a changed checksum triggers package resolution. Confirm that an existing test changes the checksum between installs. Add one if it does not.As per path instructions, tests must meaningfully verify checksum drift fallback.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm11/installing/deps-installer/test/install/pnpmfileFastUpdate.ts` around lines 115 - 121, Review the tests using calculatePnpmfileChecksum and confirm they perform installs with different checksum values between runs. If no test covers this drift, add coverage that changes the returned checksum and verifies package resolution is triggered, while preserving the existing unchanged-checksum and no-checksum-hook cases.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pnpm11/installing/deps-installer/test/install/pnpmfileFastUpdate.ts`:
- Around line 115-121: Review the tests using calculatePnpmfileChecksum and
confirm they perform installs with different checksum values between runs. If no
test covers this drift, add coverage that changes the returned checksum and
verifies package resolution is triggered, while preserving the existing
unchanged-checksum and no-checksum-hook cases.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f45bb88a-0822-4f0b-ad75-df904c47486d
📒 Files selected for processing (2)
pnpm11/installing/deps-installer/src/install/index.tspnpm11/installing/deps-installer/test/install/pnpmfileFastUpdate.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- pnpm11/installing/deps-installer/src/install/index.ts
|
Code review by qodo was updated up to the latest commit 2e374b0 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
The pnpmfile checksum deliberately excludes the global pnpmfile, so a readPackage hook it contributes can drift without pnpmfileChecksum moving. requireHooks now reports hasUntrackedReadPackageHook when a checksum-excluded pnpmfile exports readPackage, and the fast-update gate requires the flag to be off in addition to the checksum calculator being present. The flag also gives API consumers composing their own hooks with pnpmfile hooks an explicit way to keep the resolver in the loop.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm11/installing/deps-installer/test/install/pnpmfileFastUpdate.ts`:
- Around line 123-124: Update the test around requireHooks to create a temporary
checksum-excluded global pnpmfile and load it through the normal hook-loading
path instead of injecting a prebuilt hooks object with
hasUntrackedReadPackageHook set manually. Verify the resulting fast-update
behavior and fallback-resolution path depend on the flag produced by
requireHooks; rename the test if it remains only a downstream gate test.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: ee9b159f-e5a1-4584-b0d3-6d64e89057ed
⛔ Files ignored due to path filters (1)
pnpm11/hooks/pnpmfile/test/__fixtures__/globalReadPackage.jsis excluded by!**/__fixtures__/**
📒 Files selected for processing (4)
pnpm11/hooks/pnpmfile/src/requireHooks.tspnpm11/installing/deps-installer/src/install/extendInstallOptions.tspnpm11/installing/deps-installer/src/install/index.tspnpm11/installing/deps-installer/test/install/pnpmfileFastUpdate.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- pnpm11/installing/deps-installer/src/install/index.ts
The install-level test injected the untracked-hook flag by hand, so it kept passing even if requireHooks stopped producing the flag. It now writes a real global pnpmfile and loads it through requireHooks, covering the producer-to-consumer seam; verified to fail with the flag assignment removed.
Summary
Item 7 of #13696 — the one the issue flags as highest value: the blanket
!opts.hooks.readPackage?.lengthgate disabled every fast lockfile update for any project with a pnpmfile, exactly the population (large monorepos) where re-resolution hurts most.The premise was proven with failing tests first, then the gate turned out to be unnecessary rather than merely liftable:
getContextalready applies the composedreadPackagehook to every project manifest, so drift detection and the handlers compare hooked manifests against the hooked state the lockfile records. The adversarial case — a hook that rewrites one of the project's own specifiers (raw^1.0.0hooked to a1.0.0pin) — is absorbed correctly: the fast update keeps the hooked specifier and never writes the raw one (pinned by a test that fails if detection ran on raw manifests).pnpmfileChecksumdrift, which is not a composable field, so it falls back to the resolver. Hooks the checksum cannot vouch for keep forcing the resolver: a programmaticreadPackagehook (nocalculatePnpmfileChecksumbehind it) and a hook from the checksum-excluded global pnpmfile (reported by the newhasUntrackedReadPackageHookflag onrequireHooks) both stay on the full-resolution path, each pinned by a test.allProjectsAreUpToDatemachinery that already admits frozen-like installs for pnpmfile projects on every repeat install, so the fast path's eligibility now matches the frozen path's.pacquet has no such gate and already behaved this way; it gains the regression e2e pair (dead registry: unchanged-pnpmfile remove skips resolution and keeps the hook's transitive pin; a project-rewriting hook's recorded specifier survives a fast update untouched). Writing those tests surfaced a pre-existing recording divergence between the stacks — the TypeScript CLI records the hooked specifier for the importer entry while pacquet records the raw one — filed separately as #13769; both fast-update paths preserve whatever their resolver recorded, so neither is affected by it.
The CLI e2e that used a pnpmfile to force the resolution fallback still forces it (a newly added pnpmfile changes
pnpmfileChecksum); its comment now states the actual reason.Squash Commit Body
Checklist
already linked to it solves it.
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, claude-opus-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Performance
Bug Fixes