Repository navigation
Conversation
Six independent pacquet-side defects found while installing and building n8n with pnpm 12, all reported in #13322. Each is a divergence from the TypeScript CLI, so every fix here moves pacquet onto pnpm's existing behavior rather than inventing new behavior. Finding 2 — `allowBuilds` placeholders. When an install ignores build scripts, pnpm scaffolds one `allowBuilds` entry per package with the placeholder string `set this to true or false`. `WorkspaceSettings` demanded a boolean and refused to load the config at all, so a single pnpm 11 run poisoned the workspace for every pnpm 12 command. The value is now an `AllowBuild` enum; only decided entries reach `Config::allow_builds`, which is what pnpm's `createAllowBuildFunction` does with a non-boolean. Keeping the raw value on `WorkspaceSettings` means `pnpm config list` and the `updateConfig` hook still see what the file says. Finding 3 — the patch applier. `diffy`'s matcher is byte-exact; `@pnpm/patch-package`, which pnpm applies patches through, compares lines with trailing whitespace stripped and retries a hunk up to twenty lines either side of its recorded position. Three of n8n's fifteen patches depend on that looseness. `pacquet-patching` now applies hunks itself with pnpm's tolerances, keeping `diffy` for parsing. The file is modeled as `split('\n')` throughout, as patch-package does, so untouched CRLF lines keep their `\r` and a file without a final newline keeps that shape. Finding 4 — `npm_config_user_agent`. It was unset for install lifecycle scripts and the bare string `pnpm` for `pnpm run` / `exec` / `dlx`; n8n's `preinstall` guard compares the leading `name/version` token against `pnpm` and rejected the install. `Config::user_agent` is now threaded to all of them. It still reports `node/?` rather than the host Node version — filling that in costs a `node --version` spawn on every command, which is a separate trade-off to make. Finding 5 — regexp script selectors. `pnpm run "/^typecheck:.+/"` (and the bare `pnpm "/…/"` fallback) now selects every matching script, in single-project and recursive runs alike, mirroring `tryBuildRegExpFromCommand` + `getSpecifiedScripts`. An exact script name still wins over the pattern reading, and flags are rejected. This adds `regex` to the workspace dependencies; it was already in the lock transitively. Finding 6 — concurrent `packageManager` switches. Turbo spawns several `pnpm run` children at once; on a cold cache each one installed the pinned engine into the same host-wide global-virtual-store slot. Two things went wrong: the slot's destructive re-stage removed a directory another process was still writing, and every process re-linked the native binary with unlink-then-hardlink, pulling the executable out from under a sibling that was running it. The install is now serialized by an advisory lock (a new `pacquet_fs::DirLock`, which gives up rather than failing so a lost lock is never worse than today), and the relink skips an already-correct destination and otherwise swaps via rename. Finding 8 — reporting divergences. A frozen install whose recorded settings drifted now reports `ERR_PNPM_LOCKFILE_CONFIG_MISMATCH` naming the one field, as pnpm does, instead of `ERR_PNPM_OUTDATED_LOCKFILE` with the whole `overrides` map dumped. Ignored build scripts keep their `(patch_hash=…)` suffix, matching `dedupePackageNamesFromIgnoredBuilds`. And a deprecated package is reported once: pacquet's resolver re-emits a package it later meets at a shallower depth, so the reporter now folds the repeats away, which also stops a direct deprecation being counted among the deprecated subdependencies. All six are pacquet-only bugs; the TypeScript CLI already behaves this way, so there is nothing to mirror. Closes #13322
Descriptive parameter names, `prefix_then_alphabetical` derive order, raw strings instead of escapes, and trailing commas in multi-line macro invocations — the pre-push dylint pass.
PR Summary by Qodofix(cli): close pnpm-12-on-n8n compatibility defects
AI Description
Diagram
High-Level Assessment
Files changed (42)
|
Confidence Score: 3/5The PR is not yet safe to merge because the directory-lock ownership fix still permits a stale holder to remove a successor during owner-token publication. The successor lock directory becomes visible before its owner token is written, while stale-holder cleanup interprets a missing token as ownership and removes that directory; this can reintroduce concurrent writes to the shared engine slot. Files Needing Attention: pnpm/crates/fs/src/dir_lock.rs Reviews (5): Last reviewed commit: "fix(cli): stop a no-op script erasing it..." | Re-trigger Greptile |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis PR aligns Rust and TypeScript CLI behavior with pnpm across build policy parsing, lifecycle environments, regexp script execution, concurrent engine installation, lockfile diagnostics, deprecation reporting, and tolerant patch application. Changespnpm 12 compatibility fixes
Estimated code review effort: 5 (Critical) | ~120 minutes Assessment against linked issues
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 |
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1. pnpm11 status can end running
|
Micro-Benchmark ResultsLinux |
PR Code Suggestions ✨Latest suggestions up to d2fd3c9 Warning
Previous suggestionsSuggestions up to commit 606a89b
Suggestions up to commit bf9a078
Suggestions up to commit 394240f
✅ Suggestions up to commit affc990
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Greptile and Qodo each found a real defect in the first pass. **A failed script could be reported as passed.** Adding the `/pattern/` selector let one project run several scripts, but the recursive summary carries a single status per project and `count_failures` derives the exit code from it. A later script's success overwrote an earlier one's failure, so `--no-bail` reported the whole run green. The per-project `Status::Running` and `Status::Skipped` writes had the same effect, so the fix is a `project_failed` flag guarding all three rather than a comparison at the success site alone. The TypeScript stack has the same bug — `runRecursive.ts` assigns `'passed'` unguarded, and regexp selectors have shipped there for a while, so `pnpm -r run "/pattern/" --no-bail` is affected today. Fixed there too, per the cardinal rule; TypeScript's control-flow narrowing had been hiding it (it narrows the status to `'running'` and calls the comparison unreachable), which is why the fix tracks failed prefixes in a set rather than reading the status back. **A stale lock holder released its successor's lock.** A `DirLock` whose holder outran `abandoned_after` has already had its directory removed and recreated by the next process in line; dropping it then removed that successor's directory, handing the engine slot to two processes at once — the very race the lock exists to prevent. Acquisition now records a token in the lock directory and release only removes a lock that still carries it. **The lock's takeover tests were timing-fragile.** They used a zero abandonment threshold, which asks the wall clock and the filesystem's mtime clock to agree: on a runner whose wall clock sits ahead, the subtraction underflows and the lock reads as fresh. This is the likely cause of the Code Coverage job failing while the same suite passed locally. They now age a lock well past a non-zero threshold. **A rejected pattern was reported once per project.** The selector is now compiled once per command instead of once per project, which also answers the repeated-compilation finding: `ScriptSelector` resolves the positional up front and applies it across the workspace. **`force_link`'s rename now retries.** Replacing a file another process holds open fails on Windows with a sharing violation, and this destination is an executable several pnpm processes reach at once. Those handles clear in milliseconds, so a short backoff turns a spurious install failure into a pause.
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (4)
pnpm/crates/cli/tests/run_recursive.rs (1)
1449-1495: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd coverage for a partial pass/fail mix within one project's regexp matches.
This test only exercises the all-pass case. Add a
--no-bailvariant where one matched script fails and another (later, in declaration order) passes, then assert the project's summary status still reportsfailed— this would catch the status-overwrite issue flagged inrecursive.rs.🤖 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/run_recursive.rs` around lines 1449 - 1495, Extend recursive_run_executes_every_script_matching_a_regexp_selector with a --no-bail scenario where an earlier regexp-matched script fails and a later declaration-order match succeeds. Assert the command completes with the expected non-bailing result and summary_statuses reports the project as "failed", ensuring a passing script cannot overwrite the failed project status.pnpm/crates/patching/src/apply/tolerant.rs (1)
48-66: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument why
Push/Popdon't updateoffset.
Spliceupdates the runningoffset(Line 58) butPush/Popdon't, even though they changelines's length. This is correct only because EOF annotations (the sole source ofPush/Pop) are structurally confined to the last hunk processed, so no subsequent Splice ever needs to account for their length delta — but that invariant isn't stated anywhere, making it easy for a future change (e.g. reordering hunk processing, or a hypothetical multi-file/multi-EOF scenario) to silently break this. A short comment capturing the invariant would prevent that.As per path instructions,
**/*.{ts,tsx,rs}comments "should explain non-obvious invariants, workarounds, deliberate exceptions, or contracts" — this is exactly such a case.📝 Suggested comment
let mut offset = 0_isize; + // `Push`/`Pop` change `lines`'s length but don't touch `offset`: EOF + // annotations are structurally confined to the file's final hunk, so + // no later Splice in this loop ever needs to account for their delta. for modification in modifications {🤖 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/patching/src/apply/tolerant.rs` around lines 48 - 66, Add a short comment in the Modification::Pop/Modification::Push handling explaining that these EOF annotations are structurally confined to the final hunk, so no later Splice observes their length change and offset must not be updated. Keep the existing offset behavior unchanged.Source: Path instructions
pnpm/crates/package-manager/src/build_modules/tests.rs (1)
883-915: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winMissing regression test for patch-aware ignored-builds identity.
The corresponding fix in
build_modules.rs(re-deriving the ignored-builds key viaget_pkg_id_with_patch_hashso patched vs. unpatched copies of the same package are tracked separately) has no dedicated test here. The existingbuild_modules_collects_ignored_builds/build_modules_excludes_explicit_deny_from_ignoredfixtures have no patches configured, so they wouldn't fail if this logic regressed to the olddep_path-based key.Consider adding a test with two snapshots of the same
name@version— one carrying apatchesentry, one not — both denied by policy, and assertignored_buildscontains two distinct entries.
Would you like me to draft this test?🤖 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/package-manager/src/build_modules/tests.rs` around lines 883 - 915, The test suite lacks coverage for patch-aware ignored-build identity. Add a regression test alongside build_modules_collects_ignored_builds and build_modules_excludes_explicit_deny_from_ignored that creates two denied snapshots with the same name and version, but only one with a patches entry, then assert ignored_builds contains two distinct entries keyed through get_pkg_id_with_patch_hash.pnpm/crates/cli/src/cli_args/with/install_pnpm_to_store.rs (1)
159-174: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winLock-acquisition I/O errors are silently collapsed into "couldn't get the lock."
DirLock::acquirereturnsio::Result<Option<DirLock>>: the outerResultis a genuine I/O failure (e.g., can't create the lock's parent directory), while the innerOptionis "gave up waiting.".ok().flatten()discards the distinction, so a real I/O error is silently treated the same as ordinary contention, with no log/diagnostic. In practice the same I/O problem would likely resurface whencreate_dir_all(&tmp_install_dir)runs a few lines later (Line 127), but that's incidental, not a guarantee — a different transient failure (e.g., of the lock's own parent dir) would be swallowed with zero signal.As per path instructions,
pnpm/CODE_STYLE_GUIDE.mdstates "Error handling: minimizeunwrap()in non-test code; use proper Result propagation... don't swallow errors."♻️ Proposed fix: log the error case distinctly from a mere timeout
fn engine_install_lock(config: &Config, package_name: &str, version: &str) -> Option<DirLock> { ... let name = format!("{}@{version}.lock", package_name.replace('/', "+")); let path = config.store_dir.tmp().join("engine-locks").join(name); - DirLock::acquire(path, WAIT, ABANDONED_AFTER).ok().flatten() + match DirLock::acquire(path, WAIT, ABANDONED_AFTER) { + Ok(lock) => lock, + Err(error) => { + tracing::warn!(%error, "failed to take the engine install lock; proceeding unserialized"); + 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/with/install_pnpm_to_store.rs` around lines 159 - 174, Update engine_install_lock to handle the outer io::Result from DirLock::acquire separately from the inner timeout Option: preserve None for ordinary lock contention, but log or otherwise report the I/O error before returning None. Do not use .ok().flatten(), so failures creating or accessing the lock directory are not silently swallowed.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.
Inline comments:
In `@pnpm/crates/cli/src/cli_args/global.rs`:
- Line 368: Update the allow-build application flow around decided_allow_builds
and apply_allow_build() to merge approvals from WorkspaceSettings.allow_builds
with the newly selected packages before calling set_allow_build(). Preserve
existing true/false entries from raw settings, including entries absent from
config.allow_builds, while still applying the current allow_builds decision.
In `@pnpm/crates/cli/src/cli_args/run.rs`:
- Around line 494-508: Update try_build_regex_from_command to compile and match
/pattern/ selectors using JavaScript RegExp semantics instead of Rust
regex::Regex, including look-around and backreference constructs. Preserve the
existing literal parsing, flag rejection, and plain-name fallback behavior,
while ensuring valid JavaScript selectors such as /^(build|test)$/ select
matching scripts rather than being treated as names.
In `@pnpm/crates/cli/src/cli_args/run/recursive.rs`:
- Around line 173-179: The inline hidden-script error check in the recursive run
loop should filter matched hidden scripts rather than immediately returning.
After regexp matching populates recursive specified selections, reuse
throw_or_filter_hidden_scripts for the specified matches so dot-prefixed entries
are removed unless every selected script in that project is hidden, preserving
write_recursive_summary and rejecting only when no match is actionable.
- Around line 142-227: Preserve the strongest per-project outcome across all
scripts matched by the selector in the recursive run loop. Update the status and
associated duration, message, and prefix handling around the `result[root]`
assignments in the `selected` loop so later `Skipped` or `Passed` results cannot
overwrite an earlier `Failure` (and later `Skipped` cannot overwrite a prior
executed result); retain failure details for `--no-bail` summaries and failure
counting.
In `@pnpm/crates/cli/tests/lifecycle_scripts.rs`:
- Around line 1444-1486: Expand
stamps_the_configured_user_agent_on_install_scripts_and_run to configure a
distinctive npm_config_user_agent and assert the exact value rather than only
checking the pnpm prefix. Add integration coverage for the changed propagation
paths: exec, dlx, dependency-build hooks, and git preparation, ensuring each
records and validates the configured value and would fail without the spawn-path
fix.
---
Nitpick comments:
In `@pnpm/crates/cli/src/cli_args/with/install_pnpm_to_store.rs`:
- Around line 159-174: Update engine_install_lock to handle the outer io::Result
from DirLock::acquire separately from the inner timeout Option: preserve None
for ordinary lock contention, but log or otherwise report the I/O error before
returning None. Do not use .ok().flatten(), so failures creating or accessing
the lock directory are not silently swallowed.
In `@pnpm/crates/cli/tests/run_recursive.rs`:
- Around line 1449-1495: Extend
recursive_run_executes_every_script_matching_a_regexp_selector with a --no-bail
scenario where an earlier regexp-matched script fails and a later
declaration-order match succeeds. Assert the command completes with the expected
non-bailing result and summary_statuses reports the project as "failed",
ensuring a passing script cannot overwrite the failed project status.
In `@pnpm/crates/package-manager/src/build_modules/tests.rs`:
- Around line 883-915: The test suite lacks coverage for patch-aware
ignored-build identity. Add a regression test alongside
build_modules_collects_ignored_builds and
build_modules_excludes_explicit_deny_from_ignored that creates two denied
snapshots with the same name and version, but only one with a patches entry,
then assert ignored_builds contains two distinct entries keyed through
get_pkg_id_with_patch_hash.
In `@pnpm/crates/patching/src/apply/tolerant.rs`:
- Around line 48-66: Add a short comment in the
Modification::Pop/Modification::Push handling explaining that these EOF
annotations are structurally confined to the final hunk, so no later Splice
observes their length change and offset must not be updated. Keep the existing
offset behavior unchanged.
🪄 Autofix (Beta)
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: b14c05f2-8319-4b2e-b3ad-1e4776e50471
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (41)
.changeset/allow-builds-placeholder-is-parsable.md.changeset/concurrent-package-manager-switch.md.changeset/deprecated-and-ignored-build-lists.md.changeset/lockfile-config-mismatch-code.md.changeset/npm-config-user-agent-in-scripts.md.changeset/patch-applier-tolerances.md.changeset/regexp-script-selectors.mdCargo.tomlpnpm/crates/cli/Cargo.tomlpnpm/crates/cli/src/cli_args/dlx.rspnpm/crates/cli/src/cli_args/exec.rspnpm/crates/cli/src/cli_args/global.rspnpm/crates/cli/src/cli_args/run.rspnpm/crates/cli/src/cli_args/run/recursive.rspnpm/crates/cli/src/cli_args/run/tests.rspnpm/crates/cli/src/cli_args/self_update/install_pnpm.rspnpm/crates/cli/src/cli_args/with/install_pnpm_to_store.rspnpm/crates/cli/tests/approve_builds.rspnpm/crates/cli/tests/lifecycle_scripts.rspnpm/crates/cli/tests/run.rspnpm/crates/cli/tests/run_recursive.rspnpm/crates/cli/tests/with.rspnpm/crates/config/src/lib.rspnpm/crates/config/src/workspace_yaml.rspnpm/crates/config/src/workspace_yaml/tests.rspnpm/crates/default-reporter/src/state.rspnpm/crates/default-reporter/src/tests.rspnpm/crates/fs/src/dir_lock.rspnpm/crates/fs/src/dir_lock/tests.rspnpm/crates/fs/src/lib.rspnpm/crates/lockfile/src/freshness.rspnpm/crates/package-manager/src/build_modules.rspnpm/crates/package-manager/src/build_modules/tests.rspnpm/crates/package-manager/src/install.rspnpm/crates/package-manager/src/install/tests.rspnpm/crates/package-manager/src/install_frozen_lockfile.rspnpm/crates/package-manager/src/install_package_by_snapshot.rspnpm/crates/package-manager/src/patch.rspnpm/crates/patching/src/apply.rspnpm/crates/patching/src/apply/tolerant.rspnpm/crates/patching/src/apply/tolerant/tests.rs
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (1)
pnpm/crates/fs/src/dir_lock.rs (1)
22-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the ownership contract rather than restating declarations.
These rustdoc comments repeat the constant/type names. Keep
DirLockdocumentation focused on its token-validated release invariant; remove or replace the constant comments with rationale. As per coding guidelines, comments must explain non-obvious invariants, workarounds, exceptions, or contracts rather than restate code.🤖 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/fs/src/dir_lock.rs` around lines 22 - 29, Update the rustdoc around POLL_INTERVAL, OWNER_FILE, and DirLock to avoid repeating their declarations. Document the ownership contract and token-validated release invariant for DirLock, and replace the constant comments with concise rationale only where the behavior is non-obvious.Source: Coding guidelines
🤖 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/recursive-run-keeps-failures.md:
- Around line 2-4: Update the changeset frontmatter to be pacquet-only by
removing the `@pnpm/exec.commands` and pnpm entries, while retaining "pacquet":
patch as the sole release target.
In `@pnpm/crates/cli/src/cli_args/run/tests.rs`:
- Around line 45-46: Update the comment describing the pnpm selector behavior
near the test to use the correct regex terminology: state that the pattern is
not implicitly anchored to the whole script name, while preserving the examples
about matching “build” and manifest declaration order.
In `@pnpm/crates/fs/src/dir_lock.rs`:
- Around line 65-69: Update the lock-acquisition path returning DirLock to
propagate fs::write(path.join(OWNER_FILE), &token) failures instead of ignoring
them. In the release logic, ensure missing or unreadable owner records fail
closed rather than being treated as releasable, including the NotFound handling
near the existing release check.
- Around line 95-100: Replace the read-then-remove ownership check around
OWNER_FILE and fs::remove_dir_all with an ownership-bound lock/lease protocol
that atomically verifies the current holder before cleanup, preventing a
successor lock from being deleted. Update the lock release implementation to
preserve successor ownership and add a deterministic interleaving regression
test that pauses after ownership validation, performs reclaim and successor
creation, then resumes release and verifies the successor directory remains
intact.
In `@pnpm11/exec/commands/src/runRecursive.ts`:
- Around line 182-188: Guard the `running` status assignment in the recursive
execution flow around `failedPrefixes` so it only runs when
`!failedPrefixes.has(prefix)`, preserving an existing `failure` status for
queued matching scripts. Extend the regression test covering failed projects to
use `workspaceConcurrency: 1` and verify the failure remains in the final
summary.
---
Nitpick comments:
In `@pnpm/crates/fs/src/dir_lock.rs`:
- Around line 22-29: Update the rustdoc around POLL_INTERVAL, OWNER_FILE, and
DirLock to avoid repeating their declarations. Document the ownership contract
and token-validated release invariant for DirLock, and replace the constant
comments with concise rationale only where the behavior is non-obvious.
🪄 Autofix (Beta)
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: 0106f966-70a0-42d4-acfd-ec9f9b131d14
📒 Files selected for processing (10)
.changeset/recursive-run-keeps-failures.mdpnpm/crates/cli/src/cli_args/run.rspnpm/crates/cli/src/cli_args/run/recursive.rspnpm/crates/cli/src/cli_args/run/tests.rspnpm/crates/cli/src/cli_args/self_update/install_pnpm.rspnpm/crates/cli/tests/run_recursive.rspnpm/crates/fs/src/dir_lock.rspnpm/crates/fs/src/dir_lock/tests.rspnpm11/exec/commands/src/runRecursive.tspnpm11/exec/commands/test/runRecursive.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- pnpm/crates/cli/src/cli_args/self_update/install_pnpm.rs
- pnpm/crates/cli/src/cli_args/run/recursive.rs
- pnpm/crates/cli/src/cli_args/run.rs
|
Code review by qodo was updated up to the latest commit 394240f |
Deciding a package whose `allowBuilds` entry still held pnpm's `set this to true or false` placeholder wrote `true this to true or false`: the value span ended at its first whitespace, and everything past that was preserved as if it were a trailing comment. The result is a plain scalar, which YAML reads as a string — so the approval silently did nothing and the entry stayed undecided. The span now runs to a real trailing comment (` #`, outside any quoted scalar) or to the end of the line, which is what the "preserve the comment" intent was reaching for. Only reachable since this branch made a placeholder-bearing config load at all, which is why it surfaces here. Found by a reviewer asking whether `--allow-build` could drop unrelated entries; it cannot — `set_allow_builds` edits the document per named entry rather than rewriting the map — but the entry it does name was being corrupted. Also extends the user-agent test to `pnpm exec`, whose child environment is built separately from the lifecycle executor's.
|
Code review by qodo was updated up to the latest commit bf9a078 |
The TypeScript counterpart had the same trap the Rust side did: with a RegExp selector matching several scripts in one project, the per-script `result[prefix].status = 'running'` write resets a project that has already failed. Its later success is guarded, so the status is simply left at 'running' — which countFailures counts no more than 'passed', so `--no-bail` still exits zero. Guarded by the same failed-prefix set as the 'passed' write. The test now pins workspaceConcurrency to 1 so the two matched scripts run one after the other: concurrently they both set 'running' before either finishes, which hides this ordering. Also from review: - `DirLock::acquire` no longer hands back a lock whose owner record it could not write. Such a lock cannot tell at release time whether it is still the one it took, so the directory is given back and the lock reported as not taken — the documented degradation is to proceed unserialized, which is no worse than not having tried. - The release-time ownership check is documented as narrowing rather than closing the takeover window; an atomic compare-and-remove has no portable filesystem API. - Corrected a comment that called `/^build/` "not anchored" when what is meant is that the pattern is not implicitly anchored to the whole script name.
Summary
Closes #13322 — the six pacquet-side defects found while installing and building n8n with pnpm 12. Each one is a divergence from the TypeScript CLI, so every fix moves pacquet onto pnpm's existing behavior rather than inventing new behavior. Three of the six were outright blockers for that repo.
Finding 2 — an
allowBuildsplaceholder hard-blocked every command. When an install ignores build scripts, pnpm scaffolds oneallowBuildsentry per package with the placeholder stringset this to true or false.WorkspaceSettingsdemanded a boolean and refused to load the config at all, so a single pnpm 11 run poisoned the workspace for every pnpm 12 command. The value is now anAllowBuildenum; only decided entries reachConfig::allow_builds, which is what pnpm'screateAllowBuildFunctiondoes with a non-boolean. The raw value stays onWorkspaceSettings, sopnpm config listand theupdateConfighook still see what the file says.Finding 3 — the patch applier was stricter than pnpm's.
diffy's matcher is byte-exact;@pnpm/patch-package, which pnpm applies patches through, compares lines with trailing whitespace stripped and retries a hunk up to twenty lines either side of its recorded position. Three of n8n's fifteen patches depend on that looseness — a hunk whose last line is context in a file with no final newline, and an LF patch against a CRLF file.pacquet-patchingnow applies hunks itself with pnpm's tolerances, keepingdiffyfor parsing. The file is modeled assplit('\n')throughout, as patch-package does, so untouched CRLF lines keep their\rand a file without a final newline keeps that shape.Finding 4 —
npm_config_user_agentwas unset or truncated. Unset for install lifecycle scripts, the bare stringpnpmforpnpm run/exec/dlx. n8n'spreinstallguard compares the leadingname/versiontoken againstpnpmand rejected the install.Config::user_agentis now threaded to all of them.Finding 5 — regexp script selectors.
pnpm run "/^typecheck:.+/"(and the barepnpm "/…/"fallback) now selects every matching script, in single-project and recursive runs alike, mirroringtryBuildRegExpFromCommand+getSpecifiedScripts. An exact script name still wins over the pattern reading, and flags are rejected withERR_PNPM_UNSUPPORTED_SCRIPT_COMMAND_FORMAT.Finding 6 — concurrent
packageManagerswitches raced. Turbo spawns severalpnpm runchildren at once; on a cold cache each installed the pinned engine into the same host-wide global-virtual-store slot. Two things went wrong: the slot's destructive re-stage removed a directory another process was still writing, and every process re-linked the native binary with unlink-then-hardlink, pulling the executable out from under a sibling that was running it. The install is now serialized by an advisory lock, and the relink skips an already-correct destination and otherwise swaps via rename. The new integration test spawns 7 concurrent engine installs and fails reliably without either half of the fix.Finding 8 — reporting divergences. A frozen install whose recorded settings drifted now reports
ERR_PNPM_LOCKFILE_CONFIG_MISMATCHnaming the one field, as pnpm does, instead ofERR_PNPM_OUTDATED_LOCKFILEwith the wholeoverridesmap dumped. Ignored build scripts keep their(patch_hash=…)suffix, matchingdedupePackageNamesFromIgnoredBuilds. And a deprecated package is reported once — pacquet's resolver re-emits a package it later meets at a shallower depth, so the reporter folds the repeats away, which also stops a direct deprecation being counted among the deprecated subdependencies.What review changed
Four defects surfaced during review, three of them in this PR's own code:
Status::Runningwrite — erased an earlier failure from the per-project summary thatcount_failuresreads. Under--no-bailthe run exited zero. The same bug exists in the TypeScript stack, where RegExp selectors have shipped for a while, sopnpm -r run "/pattern/" --no-bailis affected today; fixed in both, which is why this PR now touchesexec/commandsand its changeset names the TypeScript package.replace_bool_value_atended the value span at its first whitespace, so deciding a package whoseallowBuildsentry still readset this to true or falsewrotetrue this to true or false— a plain scalar YAML reads as a string, leaving the package undecided and the approval silently ineffective. Only reachable because finding 2 made such a config load at all.DirLockpastabandoned_afterhad already lost its directory to the next process; dropping it removed that one, handing the engine slot to two processes at once — the exact race the lock exists to prevent. Acquisition now records an owner token and release only removes a lock still carrying it.Also from review: the selector is compiled once per command instead of once per project (which also reports a rejected pattern once rather than per project), and
force_link's rename retries briefly against the sharing violations a concurrently-running executable invites on Windows.Declined, with reasoning on the threads: switching to JavaScript RegExp semantics (needs a new dependency; the fallback matches pnpm's own behavior for an uncompilable pattern), filtering rather than aborting on a hidden script matched by a selector (pnpm aborts too), and making the changeset pacquet-only (the fix lands in both stacks).
Notes for reviewers
pacquetonly.regex(approved before adding), needed for finding 5. It was already inCargo.locktransitively, so no new supply-chain surface.regexlacks JavaScript's lookahead and backreferences; a pattern it can't compile falls through to the plain-name reading and surfaces as the usual "missing script" error, which is also what pnpm does with an invalid literal.DirLockgives up rather than failing. After a bounded wait it reports that it could not take the lock and the caller proceeds unserialized — a lost lock is never worse than today's behavior. A lock directory older than a separate, larger abandonment bound is taken over, so a process that dies holding it can't wedge the host.node/?where pnpm reportsnode/v24.18.0. Filling that in costs anode --versionspawn on every command, which is a perf trade-off worth deciding separately.Squash Commit Body
Checklist
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).
Summary by CodeRabbit
New Features
runcommands.Bug Fixes
allowBuildsplaceholders no longer block commands.