Repository navigation
Conversation
The fast path required the lockfile's importer count to equal the project count whenever pruneLockfileImporters was on — which is the default for an unfiltered recursive install — so deleting a package from a workspace always paid a full resolution. The importers handler now drops importer entries no project claims and records their aliases as dropped, leaving the shared epilogue to prune whatever that orphans, and the gate only requires that no project is *missing* an importer. A stale importer that a surviving importer still links to keeps the resolver: a project that is gone while something depends on it is a broken workspace, which must be reported rather than quietly rewritten — the behavior an existing multipleImporters test already pinned. No pacquet mirror yet: it does not prune stale importers at all, filed as #13783. Item 3 of #13696.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughFast lockfile updates can remove stale workspace importers and prune dependencies used only by them. The flow preserves shared dependencies and falls back to resolution when surviving projects link to removed workspace packages. ChangesRemoved importer fast update
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Install
participant FastUpdate
participant Lockfile
participant Resolver
Install->>FastUpdate: enable pruneLockfileImporters
FastUpdate->>Lockfile: detect stale importers
alt No surviving link targets a stale importer
FastUpdate->>Lockfile: remove stale importers and exclusive dependencies
else Surviving link targets a stale importer
FastUpdate->>Resolver: fall back to resolution
end
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ 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 Qodoperf: Prune stale workspace importers during fast lockfile updates
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "test: pin that the pruned-importer fast ..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/src/install/tryFastUpdateImporters.ts`:
- Around line 42-63: Port the stale-importer handling from the TypeScript
fast-update flow to the Rust pacquet implementation: prune stale importers,
reject fast updates when a stale importer is still linked from a surviving
project, and drop their specifier aliases through the existing graph-edit
cleanup path. Add regression coverage for workspace removal and include the Rust
release target in the changeset when the behavior is complete.
In `@pnpm11/installing/deps-installer/test/install/removedImporterFastUpdate.ts`:
- Around line 110-112: Update the install rejection assertion in the
removedImporterFastUpdate test to verify the specific
ERR_PNPM_WORKSPACE_PKG_NOT_FOUND error code instead of accepting any thrown
error. Preserve the existing invalid workspace dependency setup and ensure the
assertion checks the fallback resolution error.
🪄 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: b6e04e0d-cd92-4d18-addf-a56a18764f1b
📒 Files selected for processing (5)
.changeset/removed-importer-fast-update.mdpnpm11/installing/deps-installer/src/install/index.tspnpm11/installing/deps-installer/src/install/tryComposeFastUpdates.tspnpm11/installing/deps-installer/src/install/tryFastUpdateImporters.tspnpm11/installing/deps-installer/test/install/removedImporterFastUpdate.ts
The suite now runs the same workspace removal through the fast path and through forceFullResolution and requires the two lockfiles to be deep-equal, which is what makes this a path change rather than a behavior change. The linked-survivor test asserts ERR_PNPM_WORKSPACE_PKG_NOT_FOUND instead of accepting any rejection.
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Code Review by Qodo
1. Missing comma in isLinkedFromASurvivor params
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Summary
Item 3 of #13696, narrowed to the half that is actually broken.
The item covered adding and removing a dependency-free workspace package. Measured first: adding one already works —
getContextseeds an empty importer for every project before the gate runs, so the counts match and the frozen path handles it with zero package requests. Removing one does not: the lockfile then holds an importer no project claims, the count checkimporters.length === projects.lengthfails, and the install pays a full re-resolution. That check is live for ordinary workspace installs, sincepruneLockfileImportersdefaults to true for an unfiltered recursive install.The importers handler now drops importer entries no project claims and records their aliases as dropped, so the shared epilogue prunes whatever that orphans, recomputes
optionalflags, and applies the peer-suffix guard. The gate only requires that no project is missing an importer. This is not limited to dependency-free projects as the item framed it — a departing project with dependencies works the same way, because pruning orphans is what the epilogue already does.A guard the existing tests earned: removing a project that a surviving project still links to must fail, and my first cut silently succeeded, leaving a project depending on something that no longer exists.
multipleImporters.ts's "some projects were removed from the workspace and the ones that are left depend on them" caught it. Such a stale importer now keeps the resolver, with its own regression test alongside.No pacquet mirror. pacquet does not prune stale importers at all — verified with a workspace where the removed project's importer survives the reinstall — so there is no behavior to make fast yet. That is a divergence in its own right (the stale importer is a root in every reachability walk, so it also keeps dead packages alive), filed as #13783; the mirror belongs with it.
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
New Features
Bug Fixes