Repository navigation
fix: stop wiping depsRequiringBuild from the lockfile on repeat installs - #10551
Conversation
PR Summary by QodoFix lockfile depsRequiringBuild preservation on repeat installs
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Invalid bit lockfile block
|
| // Report every package with install scripts (not just blocked ones) in | ||
| // `depsRequiringBuild`, so the `bit:` lockfile block lists them even | ||
| // though Bit allows the builds to run. | ||
| returnListOfDepsRequiringBuild: true, |
There was a problem hiding this comment.
1. Install option ignored 🐞 Bug ≡ Correctness
lynx.install() hard-codes returnListOfDepsRequiringBuild: true, so callers cannot disable this behavior even though it is exposed as a public PackageManagerInstallOptions flag and is forwarded by PnpmPackageManager. This breaks the expected configurability and can add unnecessary work to installs that intentionally keep the flag off.
Agent Prompt
### Issue description
`scopes/dependencies/pnpm/lynx.ts` currently sets `returnListOfDepsRequiringBuild: true` unconditionally, which overrides the caller-provided `options.returnListOfDepsRequiringBuild`.
This is a behavioral regression because the public API (`PackageManagerInstallOptions`) exposes this flag as optional, and `PnpmPackageManager` forwards it, so callers expect it to be respected.
### Issue Context
- `lynx.install()` accepts `returnListOfDepsRequiringBuild?: boolean` in its `options` parameter.
- `PnpmPackageManager.install()` forwards `installOptions.returnListOfDepsRequiringBuild` into `lynx.install()`.
- The current PR hard-codes `returnListOfDepsRequiringBuild: true` in the `installOptions` passed to `nodeApi.install()`.
### Fix Focus Areas
- scopes/dependencies/pnpm/lynx.ts[416-423]
### Suggested fix
Change the hard-coded value to honor the incoming option while keeping the desired default behavior, e.g.:
- `returnListOfDepsRequiringBuild: options.returnListOfDepsRequiringBuild ?? true`
(If the intent is to *always* force this on for all installs, then remove/deprecate the public option and stop forwarding it from `PnpmPackageManager` to avoid a misleading API.)
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| export function mergeBitLockfileAttrs( | ||
| preInstallAttrs: Partial<BitLockfileAttributes> | undefined, | ||
| sortedDepsRequiringBuild: string[] | undefined | ||
| ): Partial<BitLockfileAttributes> | undefined { | ||
| if (sortedDepsRequiringBuild == null) return preInstallAttrs; | ||
| return { ...preInstallAttrs, depsRequiringBuild: sortedDepsRequiringBuild }; |
There was a problem hiding this comment.
1. Invalid bit lockfile block 🐞 Bug ≡ Correctness
When the install returns no depsRequiringBuild list, mergeBitLockfileAttrs() returns preInstallAttrs unchanged; if it lacks depsRequiringBuild, addBitAttributesToLockfile() will write a bit: block missing a required field. This creates a lockfile block that violates the declared BitLockfileAttributes shape and may confuse/ break code that expects depsRequiringBuild to be present.
Agent Prompt
### Issue description
`mergeBitLockfileAttrs()` can return a `preInstallAttrs` object that does not contain `depsRequiringBuild` when `sortedDepsRequiringBuild` is `undefined`. Later, `addBitAttributesToLockfile()` merges and casts this object to `BitLockfileAttributes` and writes it into `pnpm-lock.yaml`, which can produce a `bit:` block missing the required `depsRequiringBuild` array.
### Issue Context
This path is reachable specifically when the engine does not compute `depsRequiringBuild` (e.g. frozen-lockfile path / older engine) and the pre-existing `bit` block is partial (e.g. contains only `restoredFromModel`).
### Fix Focus Areas
- scopes/dependencies/pnpm/lynx.ts[813-819]
- scopes/dependencies/pnpm/lynx.ts[843-851]
- scopes/dependencies/pnpm/lynx.ts[861-864]
### Suggested fix
Ensure `depsRequiringBuild` is present whenever writing a `bit:` block, e.g.:
- In `mergeBitLockfileAttrs()`, when returning `preInstallAttrs` because `sortedDepsRequiringBuild` is `undefined`, return `undefined` unless `preInstallAttrs?.depsRequiringBuild` exists; OR
- Normalize to `{ ...preInstallAttrs, depsRequiringBuild: preInstallAttrs?.depsRequiringBuild ?? [] }` before calling `addBitAttributesToLockfile()`.
Pick the behavior that matches the intended lockfile schema (currently `BitLockfileAttributes.depsRequiringBuild` is required).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit b63435d |
|
Heads up on the red The job dies at
So For what it is worth on the memory question: I have deliberately not retuned that job here, since picking the number needs data on the step's real peak heap and it is unrelated to the lockfile fix in this PR. Happy to dig into the memory profile in a separate PR if that is useful. Nothing in this PR reaches that path: on the pinned Written by an agent (Claude Code, claude-fable-5). |
The napi migration dropped the returnListOfDepsRequiringBuild install option (the Rust engine did not support it), so installResult.depsRequiringBuild only carried blocked builds. Bit allows dependency builds to run, so every install reported an empty list and overwrote the bit.depsRequiringBuild lockfile block with []. Preserve the previously recorded list whenever the engine returns no list (frozen-path installs, or an engine predating the option), and pass returnListOfDepsRequiringBuild: true again so engines that support it report the full list on fresh resolves, matching the pre-migration TypeScript engine behavior. Co-Authored-By: Claude Fable 5 <[email protected]>
Extract sortDepsRequiringBuild and mergeBitLockfileAttrs from the install body so the wipe this PR fixes is pinned by a unit test: an uncomputed list (undefined) preserves the recorded block, while a computed empty list replaces it. Co-Authored-By: Claude Fable 5 <[email protected]>
… again beta.3 is the first release carrying `returnListOfDepsRequiringBuild` (pnpm/pnpm#13532), so the option this branch already passes now takes effect: a fresh resolve reports every package whose files carry install scripts instead of only the blocked ones. Verified in this repo, where the block had already been wiped to `[]` on master: a fresh resolve restores all twelve entries, and a repeat install leaves them untouched. Drop three version bridges the bump makes unnecessary. The `InstallOptions` intersection for `returnListOfDepsRequiringBuild` and the `ReadPackageHook` cast for the `resolvedDir` parameter are both in the published typings now, and `explicitSettings` is no longer optional, so getNetworkConfig can read it without a structural cast. The lockfile shrinks by about 6700 lines. 704 of the 758 removed keys carry peer suffixes, which is beta.3 deduplicating peer variants rather than dropping packages; install and compile both pass against the result. Co-Authored-By: Claude Fable 5 <[email protected]>
b63435d to
290fcdf
Compare
|
Updated for beta.3 is the first release carrying Verified in this repo:
The restored list is identical to the one that was lost: bit:
depsRequiringBuild:
- '@apollo/[email protected]'
- '@parcel/[email protected]'
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]Also dropped three version bridges the bump makes unnecessary: the One thing worth a reviewer's eye: the lockfile shrinks by roughly 6700 lines. That is not this PR changing resolution behavior by hand, it is beta.3 resolving the graph with fewer peer variants. 704 of the 758 removed keys carry peer suffixes, and Local verification: Written by an agent (Claude Code, claude-fable-5). |
|
Code review by qodo was updated up to the latest commit 290fcdf |
Summary
After the pnpm-v12/napi migration (#10508), every
bit installwiped thebit.depsRequiringBuildblock frompnpm-lock.yaml:Root cause: the migration dropped the
returnListOfDepsRequiringBuild: trueinstall option (the napi engine did not implement it), soinstallResult.depsRequiringBuildonly carried blocked builds. Bit allows dependency builds to run, so the list was always empty — and lynx wrote that empty list over the recorded block on every install.The fix:
depsRequiringBuildundefined): frozen-path repeat installs, and engines that predate the option. Verified against the currently pinned@pnpm/napi12.0.0-beta.2 — a repeat install in this repo now leaves the block byte-identical.returnListOfDepsRequiringBuild: trueagain. Engine support was added in feat(napi): add returnListOfDepsRequiringBuild install option pnpm/pnpm#13532, so the next@pnpm/napirelease reports the full list (every package whose files carry install scripts, regardless of the allow-build policy) on fresh resolves — the same semantics the pre-migration TypeScript engine had.Written by an agent (Claude Code, claude-fable-5).