Repository navigation
fix(deploy): drop excluded optional edges from the deployed lockfile - #13641
Conversation
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? |
|
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 (4)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthrough
ChangesOptional dependency deploy pruning
Estimated code review effort: 3 (Moderate) | ~20 minutes Assessment against linked issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 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 |
Confidence Score: 5/5The PR appears safe to merge. The previously reported coverage gap is resolved by asserting that node_modules/lib exists after the production deployment, while the same test separately verifies that optional packages and edges are removed; no blocking failure remains. Reviews (4): Last reviewed commit: "test(deploy): pin the optional edges the..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13641 +/- ##
=======================================
Coverage 88.23% 88.24%
=======================================
Files 624 624
Lines 101779 101812 +33
=======================================
+ Hits 89809 89843 +34
+ Misses 11970 11969 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
pnpm/crates/cli/src/cli_args/deploy.rs (1)
1011-1015: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider a short comment documenting the dangling-edge invariant.
This block has no inline comment explaining why
optional_dependenciesmust be cleared beforeretain. The reason (a retained snapshot's own optional-edge map can reference a package already dropped frompackages/snapshotswhen--no-optionalis used) is not obvious from the code alone. A brief comment here documents the invariant without narrating the loop mechanics.Proposed comment
if let Some(snapshots) = lockfile.snapshots.as_mut() { + // Retained snapshots can still reference optional-only packages that were + // just dropped from `packages`/`snapshots`; clear the map so no dangling + // optional edge remains in the deployed lockfile. if !include_optional { for snapshot in snapshots.values_mut() { snapshot.optional_dependencies = None; } }🤖 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 `@pnpm/crates/cli/src/cli_args/deploy.rs` around lines 1011 - 1015, Add a brief inline comment above the optional_dependencies clearing block in the deploy argument-processing flow, documenting that --no-optional must remove optional edges so retained snapshots cannot reference packages absent from packages or snapshots. Keep the existing loop behavior unchanged.pnpm/crates/cli/tests/deploy.rs (1)
179-193: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPrefer structured lockfile parsing over a raw string match for the pruned optional edge.
Line 189-193 checks for the pruned qar edge with a literal string match on YAML formatting (
"optionalDependencies:\n '@pnpm.e2e/qar'"). This is fragile: any change to indentation, quoting style, or key ordering in the lockfile serializer breaks the check without necessarily indicating a real regression.deploy_graph_keys(Line 537-546) already shows the pattern for loading the lockfile throughLockfile::load_wanted_from_dir; use that to assert directly on the parsed snapshot'soptional_dependenciesfield forlibinstead of matching raw text.Proposed refactor
- let lockfile = fs::read_to_string(without_optional.join("pnpm-lock.yaml")).unwrap(); - assert!( - !lockfile.contains("optionalDependencies:\n '`@pnpm.e2e/qar`'"), - "retained production snapshots must not keep pruned optional edges:\n{lockfile}", - ); + let deploy_lockfile = Lockfile::load_wanted_from_dir(&without_optional).unwrap().unwrap(); + let retained_optional_edges: Vec<_> = deploy_lockfile + .snapshots + .iter() + .flatten() + .filter(|(_, snapshot)| snapshot.optional_dependencies.is_some()) + .collect(); + assert!( + retained_optional_edges.is_empty(), + "retained production snapshots must not keep pruned optional edges: {retained_optional_edges:?}", + );🤖 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 `@pnpm/crates/cli/tests/deploy.rs` around lines 179 - 193, Replace the raw pnpm-lock.yaml string check in the without_optional assertions with structured parsing via Lockfile::load_wanted_from_dir, following the existing deploy_graph_keys pattern. Locate the parsed lib snapshot and assert its optional_dependencies field does not contain the pruned `@pnpm.e2e/qar` edge, while preserving the existing graph and virtual-store assertions.
🤖 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 `@pnpm/crates/cli/src/cli_args/deploy.rs`:
- Around line 1011-1015: Add a brief inline comment above the
optional_dependencies clearing block in the deploy argument-processing flow,
documenting that --no-optional must remove optional edges so retained snapshots
cannot reference packages absent from packages or snapshots. Keep the existing
loop behavior unchanged.
In `@pnpm/crates/cli/tests/deploy.rs`:
- Around line 179-193: Replace the raw pnpm-lock.yaml string check in the
without_optional assertions with structured parsing via
Lockfile::load_wanted_from_dir, following the existing deploy_graph_keys
pattern. Locate the parsed lib snapshot and assert its optional_dependencies
field does not contain the pruned `@pnpm.e2e/qar` edge, while preserving the
existing graph and virtual-store assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 79d67c43-7a3a-48d5-9f61-6ba00189f693
📒 Files selected for processing (3)
.changeset/deploy-no-optional-symlinks.mdpnpm/crates/cli/src/cli_args/deploy.rspnpm/crates/cli/tests/deploy.rs
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. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time). Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.62635602716,
"stddev": 0.1537092650515119,
"median": 2.64801952336,
"user": 1.63454628,
"system": 1.3554037199999998,
"min": 2.38782759436,
"max": 2.79811907836,
"times": [
2.58935208136,
2.70668696536,
2.3925842023599997,
2.75374474936,
2.74955257136,
2.55054788536,
2.77532021736,
2.38782759436,
2.79811907836,
2.5598249263599997
]
},
{
"command": "pacquet@main",
"mean": 2.51091394326,
"stddev": 0.15099381248142543,
"median": 2.46882950136,
"user": 1.64442598,
"system": 1.3145932200000001,
"min": 2.36020991436,
"max": 2.77700306836,
"times": [
2.4097721063599997,
2.52339999436,
2.56934339836,
2.46794383736,
2.77700306836,
2.36560302336,
2.40586813036,
2.36020991436,
2.76028079436,
2.46971516536
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5928930287600003,
"stddev": 0.1700371863244378,
"median": 1.60506542736,
"user": 1.13709068,
"system": 1.18110812,
"min": 1.3816036073600002,
"max": 1.7939154193600002,
"times": [
1.5291760863600001,
1.7939154193600002,
1.3816036073600002,
1.38351099136,
1.7159209313600001,
1.4890300893600001,
1.78463147936,
1.6809547683600001,
1.41672429436,
1.7534626203600001
]
},
{
"command": "pnpr@main",
"mean": 1.5658127343600001,
"stddev": 0.15458465181624145,
"median": 1.5437471653600001,
"user": 1.13417618,
"system": 1.19870682,
"min": 1.37796908936,
"max": 1.8025434743600002,
"times": [
1.78504473836,
1.52165144836,
1.4032912543600002,
1.52130999636,
1.5737787333600002,
1.8025434743600002,
1.5658428823600001,
1.7032815703600002,
1.40341415636,
1.37796908936
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.27139730034,
"stddev": 0.012354330238771633,
"median": 0.26929211224,
"user": 0.23170805999999997,
"system": 0.54715936,
"min": 0.25689358924,
"max": 0.29385489324,
"times": [
0.28229211824,
0.28181311524,
0.27831052824,
0.26497122624,
0.29385489324,
0.25705791824,
0.25689358924,
0.26812453824,
0.26019539024,
0.27045968624
]
},
{
"command": "pacquet@main",
"mean": 0.26180751164,
"stddev": 0.010807370084379616,
"median": 0.26285516574,
"user": 0.22436266,
"system": 0.5134236600000001,
"min": 0.24737565824,
"max": 0.28001819524,
"times": [
0.27353557124,
0.26908107924,
0.26538399424000003,
0.25245830224,
0.26035655324,
0.25568311924,
0.24737565824,
0.24882886524,
0.26535377824,
0.28001819524
]
},
{
"command": "pnpr@HEAD",
"mean": 0.27778350774000005,
"stddev": 0.00915797407543773,
"median": 0.27723274274,
"user": 0.23589756,
"system": 0.53189496,
"min": 0.26448315724,
"max": 0.29088815324,
"times": [
0.27470799024000003,
0.27055952424,
0.29088815324,
0.26448315724,
0.27665955824,
0.26725806524,
0.27845660224,
0.27780592724000003,
0.28750624224,
0.28950985724
]
},
{
"command": "pnpr@main",
"mean": 0.28328869924,
"stddev": 0.005580902759642259,
"median": 0.28186526274,
"user": 0.23947896000000002,
"system": 0.55025766,
"min": 0.27510084824000003,
"max": 0.29571654824,
"times": [
0.27510084824000003,
0.28180748424,
0.27981387724,
0.29571654824,
0.28385671524,
0.28022507224,
0.28837324324,
0.28192304124,
0.28116387124000003,
0.28490629124
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.6623770350199996,
"stddev": 0.10575974162125837,
"median": 2.61942460852,
"user": 1.72438344,
"system": 1.4465321599999998,
"min": 2.58948184502,
"max": 2.9442581680199997,
"times": [
2.60628460202,
2.58948184502,
2.61437722902,
2.6555751550199997,
2.61430503302,
2.62112166602,
2.6177275510199998,
2.63702723202,
2.72361186902,
2.9442581680199997
]
},
{
"command": "pacquet@main",
"mean": 2.6265300735199997,
"stddev": 0.02028670333447167,
"median": 2.62684522302,
"user": 1.56872444,
"system": 1.3505653599999998,
"min": 2.5961221160199996,
"max": 2.66334271002,
"times": [
2.64255970402,
2.66334271002,
2.6169971040199997,
2.63689337902,
2.63606135202,
2.63168249202,
2.59814614802,
2.62200795402,
2.5961221160199996,
2.62148777602
]
},
{
"command": "pnpr@HEAD",
"mean": 1.7007257235200002,
"stddev": 0.16439146385514894,
"median": 1.74916206402,
"user": 1.1378190399999997,
"system": 1.1962658599999998,
"min": 1.4449055210200001,
"max": 1.96326113902,
"times": [
1.8267946350200002,
1.7481951820200001,
1.5275716050200001,
1.4449055210200001,
1.75012894602,
1.96326113902,
1.7381733300200002,
1.48025611302,
1.7755972690200001,
1.75237349502
]
},
{
"command": "pnpr@main",
"mean": 1.58779127162,
"stddev": 0.14268249265481273,
"median": 1.5551298405200003,
"user": 1.0705776400000002,
"system": 1.1909982599999998,
"min": 1.44685592102,
"max": 1.8365675240200001,
"times": [
1.5089778950200001,
1.47691733902,
1.6266548680200001,
1.7915317080200002,
1.4618142760200001,
1.67026216202,
1.6012817860200002,
1.8365675240200001,
1.44685592102,
1.45704923702
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.41707824518000003,
"stddev": 0.01548632328081901,
"median": 0.41575582778,
"user": 0.53535546,
"system": 0.70658358,
"min": 0.39612561228,
"max": 0.44859419828,
"times": [
0.39612561228,
0.40232492228,
0.42501960128,
0.40856034928,
0.42886118928,
0.44859419828,
0.41112261928,
0.42432812928,
0.40545679428,
0.42038903628
]
},
{
"command": "pacquet@main",
"mean": 0.41516596488,
"stddev": 0.012335343622726149,
"median": 0.41775720228,
"user": 0.53907276,
"system": 0.68879048,
"min": 0.39663991128,
"max": 0.43331238528,
"times": [
0.43052056528,
0.41174209528,
0.42063789528,
0.42016773028,
0.41543641528,
0.42007798928,
0.43331238528,
0.40126744028,
0.40185722128,
0.39663991128
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30862294438,
"stddev": 0.00733216879963361,
"median": 0.30976518127999997,
"user": 0.21565646000000002,
"system": 0.5322266800000001,
"min": 0.29218419828,
"max": 0.32011443028,
"times": [
0.30992158628,
0.32011443028,
0.31539310428,
0.31004726328,
0.30960877628,
0.30480956428,
0.30587541228,
0.31118903428,
0.30708607428,
0.29218419828
]
},
{
"command": "pnpr@main",
"mean": 0.31131026858,
"stddev": 0.010901329337795827,
"median": 0.30994599778,
"user": 0.21681706000000003,
"system": 0.5357696800000001,
"min": 0.29036800528,
"max": 0.32962063028,
"times": [
0.32088752628,
0.31676958828,
0.31265423628,
0.30723775928,
0.30680721828,
0.29036800528,
0.30459336727999997,
0.30540394528,
0.31876040928,
0.32962063028
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.77385096514,
"stddev": 0.08107966306280023,
"median": 1.7435925498399998,
"user": 0.8518333199999999,
"system": 0.83915042,
"min": 1.7225051753399998,
"max": 1.98494894234,
"times": [
1.7411996263399998,
1.7283293683399998,
1.7466320633399999,
1.79678937334,
1.98494894234,
1.82046056234,
1.72569014534,
1.7225051753399998,
1.7259689213399998,
1.74598547334
]
},
{
"command": "pacquet@main",
"mean": 1.72865046324,
"stddev": 0.012115768869205805,
"median": 1.72776945334,
"user": 0.75804982,
"system": 0.78931642,
"min": 1.7111396613399998,
"max": 1.7519395013399999,
"times": [
1.72593753234,
1.7111396613399998,
1.72582318634,
1.71228009934,
1.7519395013399999,
1.72960137434,
1.72284735034,
1.73756979834,
1.7337193543399998,
1.73564677434
]
},
{
"command": "pnpr@HEAD",
"mean": 0.3080195795400001,
"stddev": 0.012114513022072932,
"median": 0.31336720634000004,
"user": 0.21112842,
"system": 0.5265228200000001,
"min": 0.28276932334000004,
"max": 0.32120256434000005,
"times": [
0.30551709234,
0.31478488234,
0.28276932334000004,
0.29529565334,
0.29970158434000005,
0.31533019034000004,
0.32120256434000005,
0.31793946634000003,
0.31570550834000005,
0.31194953034000006
]
},
{
"command": "pnpr@main",
"mean": 0.30404893844,
"stddev": 0.011768937270545617,
"median": 0.30742197534000004,
"user": 0.21318072,
"system": 0.51618922,
"min": 0.28373247834000004,
"max": 0.32077468834000006,
"times": [
0.31074915934,
0.30755719534000003,
0.29173982334000004,
0.29174005434000005,
0.28373247834000004,
0.31471328734000004,
0.31163101134000004,
0.32077468834000006,
0.30728675534000005,
0.30056493134
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.23688165270333336,
"stddev": 0.02979569493453565,
"median": 0.23554457862,
"user": 0.2129131533333333,
"system": 0.06084942333333334,
"min": 0.20187138912000002,
"max": 0.30504891312000004,
"times": [
0.22985987912,
0.21374168312,
0.21047525912,
0.22085762912,
0.24709625112,
0.26896884912,
0.20187138912000002,
0.20724711712000002,
0.30504891312000004,
0.24122927812,
0.25408867512000005,
0.24209490912
]
},
{
"command": "pacquet@main",
"mean": 0.24704335419142862,
"stddev": 0.0382695881032311,
"median": 0.24751050712,
"user": 0.20535353428571426,
"system": 0.07129291142857143,
"min": 0.18039860512,
"max": 0.31684610812,
"times": [
0.20578713612000002,
0.30934655012000006,
0.25500422012,
0.26363350712000005,
0.31684610812,
0.24855196512000002,
0.26463907312000007,
0.27142331312000006,
0.23551241912,
0.21383584912,
0.20685261312,
0.18039860512,
0.24030655012000002,
0.24646904912
]
},
{
"command": "pnpr@HEAD",
"mean": 0.09169147549500001,
"stddev": 0.0037286311262118774,
"median": 0.09170143612000001,
"user": 0.023185038749999994,
"system": 0.010067568750000004,
"min": 0.08650152512,
"max": 0.09929381612,
"times": [
0.08743487312,
0.09327297212,
0.09251398212,
0.09263854712,
0.09003647412,
0.09270598412,
0.09696896512,
0.09782470712,
0.09027331112,
0.08910560012,
0.09863839212,
0.09076447612,
0.08650152512,
0.08736983112,
0.09101586012,
0.08884222412000001,
0.08696173212,
0.08777526512,
0.09738189312000001,
0.08660388812,
0.08724715012,
0.08787421112,
0.09418451912,
0.09318660912,
0.09296987212,
0.09238701212,
0.09424953112000001,
0.09929381612,
0.08941893112,
0.09474980412,
0.09392673412000001,
0.09000852212
]
},
{
"command": "pnpr@main",
"mean": 0.09084072555333332,
"stddev": 0.002442069609098436,
"median": 0.09100677762,
"user": 0.023858719999999996,
"system": 0.009322722666666668,
"min": 0.08544271012,
"max": 0.09618137112,
"times": [
0.09544044612000001,
0.09107768612,
0.08923752912,
0.08982741012,
0.08858153312,
0.09215669912,
0.09235770812,
0.09241386412000001,
0.09077064812,
0.09204314512,
0.09174832912,
0.09059857412,
0.08854581612,
0.09272540112000001,
0.09109316512,
0.09093586912,
0.09216610612000001,
0.08544271012,
0.08679687212000001,
0.08696962712,
0.08859904712,
0.09261781812,
0.09050751212000001,
0.08936972812,
0.08917719612,
0.09470243512,
0.09618137112,
0.08915324112,
0.09266571812,
0.09131856012
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.7876936289066667,
"stddev": 0.12837092217789262,
"median": 0.8004537152400001,
"user": 0.7508217444444445,
"system": 0.12911178666666664,
"min": 0.57865319824,
"max": 0.9974027432400001,
"times": [
0.8895038432400001,
0.57865319824,
0.6361618132400001,
0.9974027432400001,
0.72162693724,
0.8004537152400001,
0.8373580822400001,
0.8490208252400001,
0.77906150224
]
},
{
"command": "pacquet@main",
"mean": 0.7722648092400001,
"stddev": 0.188211557595222,
"median": 0.6731049642400001,
"user": 0.7424164111111112,
"system": 0.12001711999999998,
"min": 0.63764731224,
"max": 1.1620724862399998,
"times": [
0.6731049642400001,
0.63764731224,
1.1620724862399998,
0.6615117622400001,
0.65059663824,
1.02008726924,
0.7080145122400001,
0.6680442082400001,
0.7693041302400001
]
},
{
"command": "pnpm@HEAD",
"mean": 3.162841925128889,
"stddev": 0.19815452968721603,
"median": 3.18452420924,
"user": 4.87026341111111,
"system": 0.2832355644444444,
"min": 2.92640260424,
"max": 3.44265354824,
"times": [
2.9486367922400003,
3.18452420924,
2.92640260424,
2.9372752972400002,
3.44265354824,
3.3992249392400002,
3.3039927542400003,
3.1027610782400004,
3.22010610324
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.57976693242,
"stddev": 0.16792188541852457,
"median": 4.5126471631200005,
"user": 1.9639671799999998,
"system": 1.46308076,
"min": 4.431564871120001,
"max": 4.89725285912,
"times": [
4.46810632612,
4.89725285912,
4.4739819261200005,
4.530858059120001,
4.87255276612,
4.47739054412,
4.431564871120001,
4.49443626712,
4.602690332120001,
4.54883537312
]
},
{
"command": "pacquet@main",
"mean": 4.56314823702,
"stddev": 0.10797256287470336,
"median": 4.51876771612,
"user": 2.04587008,
"system": 1.5509633600000001,
"min": 4.469115475120001,
"max": 4.7698418271200005,
"times": [
4.54714349512,
4.7698418271200005,
4.50519661912,
4.59138168712,
4.50535953612,
4.471715883120001,
4.49755792812,
4.53217589612,
4.469115475120001,
4.74199402312
]
},
{
"command": "pnpr@HEAD",
"mean": 3.54531616762,
"stddev": 0.09202951187330244,
"median": 3.5061746451199998,
"user": 1.3564079799999997,
"system": 1.2868953600000002,
"min": 3.47416486012,
"max": 3.77601825412,
"times": [
3.50327578412,
3.55896455812,
3.77601825412,
3.48337105412,
3.47416486012,
3.50907350612,
3.6015332351200002,
3.48557662012,
3.48774486012,
3.57343894412
]
},
{
"command": "pnpr@main",
"mean": 3.5393804639199997,
"stddev": 0.08080280495364371,
"median": 3.50807862862,
"user": 1.31842238,
"system": 1.35724976,
"min": 3.45452943512,
"max": 3.68505295912,
"times": [
3.51737692612,
3.45452943512,
3.47133587712,
3.47902755812,
3.46738344112,
3.58152724212,
3.49878033112,
3.62866603012,
3.61012483912,
3.68505295912
]
}
]
} |
Clear the optional edges after `retain`, so only snapshots the deploy graph actually keeps are touched. In the test, report which package leaked instead of collapsing three patterns into one boolean, reusing the `for excluded in [...]` idiom the rest of the file already uses, and parse the deploy lockfile once per assertion group. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`filterDeployPackageSnapshots` already skips optional edges when walking the graph for `--no-optional`, but returned the retained snapshots with their `optionalDependencies` maps intact — pointing at packages it had just dropped. Clear them, so the deployed lockfile cannot ask the linker to create dangling links. This is the TypeScript half of the same bug pacquet fixes in this PR; the two stacks had it in the same place. Fixes pnpm#13623 on both sides. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1dc626f to
4f9fe57
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
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 `@pnpm/crates/cli/tests/suite/deploy.rs`:
- Around line 159-165: Extend the default deploy assertions after
deploy_graph_keys(&with_optional) to load the default deploy lockfile and
inspect the lib snapshot’s optionalDependencies, asserting it retains the
`@pnpm.e2e/qar` edge. Keep the existing graph reachability checks and mirror the
regression assertion in the corresponding TypeScript CLI coverage.
In `@pnpm11/releasing/commands/test/deploy/createDeployFiles.test.ts`:
- Around line 78-134: Extend the regression coverage around createDeployFiles to
execute the pnpm11 deploy scenario with optional dependencies excluded, rather
than only inspecting the generated lockfile. Assert that the optional package
and all of its transitive dependencies are absent from deployed node_modules and
the virtual store, while retaining the lockfile assertions and keeping
TypeScript behavior aligned with the user-visible deploy result.
🪄 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: d8203d12-c26f-435e-9d1a-9d61c72aa364
📒 Files selected for processing (5)
.changeset/deploy-no-optional-symlinks.mdpnpm/crates/cli/src/cli_args/deploy.rspnpm/crates/cli/tests/suite/deploy.rspnpm11/releasing/commands/src/deploy/createDeployFiles.tspnpm11/releasing/commands/test/deploy/createDeployFiles.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- .changeset/deploy-no-optional-symlinks.md
- pnpm/crates/cli/src/cli_args/deploy.rs
Code Review by Qodo
1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…apshot Every value in the map handed to `filterDeployPackageSnapshots` is built fresh by `convertPackageSnapshot` / `convertProjectSnapshotToPackageSnapshot` and shared with nothing, so the retained snapshots can be edited in place instead of shallow-cloning one object per reachable package. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The no-optional assertions only proved the edges were gone; nothing proved they were ever there, so clearing them in both modes would have passed. Assert the default deploy keeps them, and give both stacks a dependency shaped like the one from the report — a registry package whose optional dependencies are platform-specific — plus a pnpm11 deploy integration test matching pacquet's. Correct the changeset: on current main the deploy install already skips the optional edges at link time, in both stacks. Verified against the `[email protected]` repro from pnpm#13623 — the deploy directory has no dangling links either way. What the retained edges do corrupt is the deployed lockfile, which lists optional dependencies it does not define. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
|
Code review by qodo was updated up to the latest commit 8819c01 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
| Project | pnpm's project |
| Branch | pr/13641 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,444.91 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 282.77 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 292.18 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 86.50 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,381.60 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,474.16 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 264.48 ms |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
#14069) A shared-lockfile deploy prunes the package graph to the included dependency groups but kept every direct dependency in the deployed package.json and in the deployed lockfile's importer. The deployed lockfile therefore referenced packages it did not define, and the next install in the deploy directory tripped over that: pacquet linked the missing packages and left dangling symlinks, while the TypeScript CLI refused the install with ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY. A --prod deploy of a project whose dev workspace dependency no longer exists pointed the importer at a missing directory the same way. Fill only the included groups into the deploy importer, in pacquet's create_deploy_files and in the TypeScript CLI's createDeployFiles, so the manifest, the importer, and the package graph agree. The graph walk no longer needs its own include gating for the importer maps; the snapshot-level optional handling from #13641 stays as it is. Also drop an emptied group from pacquet's deploy importer instead of writing it as `{}` — the TypeScript lockfile writer omits an empty dependency map, so the two stacks were producing different deploy lockfiles for the same input. Resolve pacquet's --prod/--dev/--no-optional flags the way the TypeScript CLI does: --prod wins over --dev, and a dev-only install drops optional dependencies along with the production ones. Without it `pnpm install --dev` installed an optional dependency pnpm skips, and the deploy change above would have carried that divergence into `pnpm deploy --dev`'s manifest and lockfile. Closes #13623
Summary
pnpm deploy --prod --no-optionalprunes the excluded optional packages from the deploy graph, but leaves theoptionalDependenciesmap on every snapshot it keeps. The deployedpnpm-lock.yamlthen lists optional dependencies that the same lockfile never defines.On the
[email protected]repro from #13623 the deployed lockfile ends up with[email protected]declaring 25@img/sharp-*optional dependencies whilepackages:andsnapshots:contain only four entries. This PR clears those edges in both stacks, so the deployed lockfile is self-consistent.Both implementations had the bug in the same place —
prune_deploy_lockfile_graphin pacquet andfilterDeployPackageSnapshotsin the TypeScript CLI — and both are fixed here.On the linked issue
This PR was opened as a fix for #13623, which reports dangling symlinks under the deployed virtual store. That symptom no longer reproduces on
main, with or without this change: running the issue's[email protected]repro against a locally built binary,pnpm deploy --prod --no-optionalyields zero dangling links in both builds. The issue was filed against12.0.0-beta.4; the linking half appears to have been fixed elsewhere between then and12.0.0-rc.3.So this is deliberately linked as Related to rather than Fixes — it repairs the corrupt deployed lockfile, which is the part that is still reproducible. Someone should re-check #13623 against
mainand close it separately if it is already resolved.Related to #13623
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.
Tests
Each new assertion was checked against a deliberately broken implementation to confirm it fails without the fix.
Written by an agent (Jeeves / Hermes Agent, gpt-5.5); reviewed, extended to the TypeScript CLI, and corrected 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
Bug Fixes
Tests