Skip to content

fix(building.during-install): resolve hoisted link destinations on the main thread - #13646

Merged
zkochan merged 4 commits into
pnpm:mainfrom
mikelehen:fix-hoisted-link-destination-cwd-race
Aug 10, 2026
Merged

zkochan merged 4 commits into
pnpm:mainfrom
mikelehen:fix-hoisted-link-destination-cwd-race

Conversation

@mikelehen

@mikelehen mikelehen commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #13627.

hardLinkDir() runs on a worker thread but is handed destinations relative to lockfileDir (during-install#L327-L329). applyPatchToDir() — called for every patchedDependencies entry — wraps patch application in a synchronous process.chdir() (apply-patch#L18-L32). The cwd is process-wide and shared with worker threads, so a worker resolving a relative destination inside that window resolves it against the patched package instead of the project root, and the rename fails with ERR_PNPM_ENOENT — or ERR_PNPM_ENOTEMPTY, depending on what happens to be at the wrong path.

Resolving the destinations on the main thread is safe because the cwd is only switched inside a synchronous block, so no other main-thread code can observe it, and hoistedLocations values are always relative (they come from path.relative).

The rebuild path (after-install#L405) already maps hoisted locations through path.join(opts.lockfileDir, hoistedLocation) before calling hardLinkDir(), so this makes install consistent with rebuild rather than introducing a new convention.

Verification

Measured on a ~2150-package workspace with two patchedDependencies entries and esbuild in three hoisted locations (macOS/APFS, pnpm 10.34.4 — same code shape as main):

pnpm patch cwd window installs failures
stock unmodified 40 23 (19 ENOENT, 4 ENOTEMPTY)
fixed unmodified 40 0
stock +800ms 8 7
fixed +800ms 8 0

The +800ms rows add a synchronous sleep inside the cwd window that applyPatchToDir already opens — no other change — which makes the failure reproduce almost every time.

With the fix applied, tracing shows worker renames still happening inside open cwd windows and simply succeeding, so this is not a timing change. Checking every path field in all six worker message types (extract, link, add-dir, symlinkAllModules, hardLinkDir, init-store) across a full install, hardLinkDir's destDirs is the only relative path any worker receives.

Test

Per the triage note, the race itself isn't directly testable, so the added test asserts the invariant instead: the destinations reaching hardLinkDir() from the install path are absolute. It fails on main (receives node_modules/bar/node_modules/foo) and passes with this change.

jest (13 tests), eslint, and cspell pass for pnpm11/building/during-install, and tsgo --build typechecks clean. I could not run the repo-wide compile-only / lint locally — pnpm's self-managed 12.0.0-beta.4 fails to install on this machine — so those are left to CI.

Note on #12880

#12880 shares the error text but is a different race, and should not be closed by this. That workspace has no patchedDependencies at all; with this fix applied its error paths are absolute, so cwd plays no part, and its repro still fails. Tracing it shows a parent/child destination overlap inside hardLinkDir itself — two hoist-copies running concurrently where one's destination is nested inside the other's, and renameOverwriteSync swap-renames the parent directory aside, carrying the other worker's staged temp with it:

0.00ms tid1   stage-begin  dest=y0/node_modules/p0/node_modules/q0
                           temp=y0/node_modules/p0/node_modules/_tmp_639b…
0.09ms tid14  stage-begin  dest=y0/node_modules/p0          <- the parent package
1.09ms tid1   stage-done   temp exists
1.53ms tid1   RENAME-FAIL  ENOENT  temp gone, temp's parent gone
3.26ms tid14  rename-ok    -> y0/node_modules/p0

That is presumably why a retry around the rename clears that repro; it would not fix the cwd race here, because the temp directory never existed at the resolved path to begin with.

Written by an agent (Claude Code, claude-opus-5).

Summary by CodeRabbit

  • Bug Fixes
    • Fixed intermittent installation rename errors in hoisted workspaces when using patched dependencies.
    • Improved installation reliability by resolving hoisted dependency destinations correctly before linking.
    • Prevented failures caused by relative destinations during hoisted dependency installation.
    • Added safeguards to help workspace installations complete consistently when linking hoisted dependencies.
    • Improved compatibility for installations that use patched dependencies alongside hoisted workspace layouts.

@mikelehen
mikelehen requested a review from zkochan as a code owner August 4, 2026 18:29
@welcome

welcome Bot commented Aug 4, 2026

Copy link
Copy Markdown

💖 Thanks for opening this pull request! 💖
Please be patient and we will get back to you as soon as we can.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The installation build path documents hoisted destination resolution before worker execution. A regression test verifies that hardLinkDir receives absolute destinations. A changeset records patch releases for the affected packages.

Changes

Hoisted destination resolution

Layer / File(s) Summary
Destination resolution and regression coverage
pnpm11/building/during-install/src/index.ts, pnpm11/building/during-install/test/hoistedLocations.test.ts, .changeset/absolute-hoisted-link-destinations.md
The install code documents main-thread path resolution. The regression test creates a hoisted layout and verifies absolute destinations passed to hardLinkDir. The changeset records patch releases for @pnpm/building.during-install and pnpm.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • pnpm/pnpm#13627 — The changes implement absolute destination handling and regression coverage described by this issue.

Suggested labels: product: pnpm@11

Suggested reviewers: zkochan

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported temporary fixture leak is fixed by unconditional recursive cleanup in the test’s finally block.

Reviews (6): Last reviewed commit: "test(building.during-install): use async..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/building/during-install/test/hoistedLocations.test.ts`:
- Around line 23-67: Wrap the temporary fixture setup, buildModules call, and
assertions in the test’s try/finally scope, then remove lockfileDir in finally
with fs.promises.rm using recursive and force options. Keep the existing
hoistedLocations assertions unchanged.
🪄 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: a184d156-300a-432f-b5f0-0e280e1c4a22

📥 Commits

Reviewing files that changed from the base of the PR and between 74bf5dd and fc2ae56.

📒 Files selected for processing (3)
  • .changeset/absolute-hoisted-link-destinations.md
  • pnpm11/building/during-install/src/index.ts
  • pnpm11/building/during-install/test/hoistedLocations.test.ts

@mikelehen

Copy link
Copy Markdown
Contributor Author

Thanks — both review comments were valid and are fixed in f21c818:

  • Temp fixture leak (@greptile-apps, @coderabbitai): the fixture setup and assertions now live in a helper called inside try, with fs.rmSync(lockfileDir, { recursive: true, force: true }) in finally. Verified the system temp directory has no pnpm-hoisted-* leftovers after a run.
  • CI Compile & Lint failure: the same test was the cause. jest.fn(async () => {}) inferred a zero-parameter signature, so mock.calls[0][1] tripped TS2493 under test/tsconfig.json. The mock now declares (src: string, destDirs: string[]) => Promise<void>, which also made the as unknown as string[] cast unnecessary. I had only run tsgo --build for src locally and missed the test project; I've now verified tsgo --build test/tsconfig.json as well.

Skipping the ast-grep detect-non-literal-fs-filename hint on line 25: the path is derived from fs.mkdtempSync inside the test, not from any external input.

Re-verified after the change: tsgo --build and tsgo --build test/tsconfig.json clean, 13/13 jest tests pass, eslint and cspell clean. I also re-checked that the test still fails without the production fix — it receives the bare relative node_modules/bar/node_modules/foo — so it remains a real regression guard.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@mikelehen Confirmed. The cleanup in finally addresses the temporary fixture leak. The typed jest.fn signature addresses TS2493 in the test project.

The reported verification is sufficient. The regression test still distinguishes the fixed behavior from the previous relative destination behavior.

The fs.rmSync filename finding does not apply here because lockfileDir originates from fs.mkdtempSync within the test.

🐇 ✅


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

You are interacting with an AI system.

@greptile-apps

greptile-apps Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Both fixes look correct:

  • Typed mock: jest.fn<(src: string, destDirs: string[]) => Promise<void>>(async () => {}) — the explicit generic gives TypeScript enough information to type mock.calls[0][1] as string[], removing the need for the cast. Clean.
  • Fixture cleanup: the try/finally around runInstall with fs.rmSync(..., { recursive: true, force: true }) correctly handles both success and failure paths. force: true means a partially-created fixture (e.g. only mkdtempSync succeeded but mkdirSync inside runInstall threw) won't cause the cleanup to throw either.

The runInstall helper factoring is tidy — it keeps the assertion logic readable while letting the top-level test own the lifecycle. LGTM.

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 4, 2026
@mikelehen

Copy link
Copy Markdown
Contributor Author

The Windows leg of the test matrix caught a real bug in my fixture, fixed in 5f10677.

The fixture hardcoded 'node_modules/foo' with forward slashes, but the install code matches the current location against path.relative(opts.lockfileDir, depNode.dir), which yields node_modules\foo on Windows. So nothing was filtered out and the test saw two destinations instead of one. Ubuntu passed on Node 22/24/26 because the separators happened to agree there.

The fixture now derives both locations with path.join(), which is also how real hoistedLocations are produced (path.relative), so it stays faithful to the data the install path actually receives. Verified the filter matches under both path.posix and path.win32 semantics.

The production change is unaffected — only the test fixture was wrong.

@mikelehen

Copy link
Copy Markdown
Contributor Author

Heads up on the one red check: TS CI / Test / windows 2/3 / Node 22 failed with

The self-hosted runner lost communication with the server.

The runner died mid-step (its logs were never uploaded), so this is infrastructure rather than the change — the earlier Windows failure on f21c818 was a real fixture bug and is fixed in 5f10677. Everything else is green: Compile & Lint, ubuntu Node 22/24/26, windows chunks 1/3 and 3/3, CodeQL, Greptile, CodeRabbit.

I don't have rerun rights here, so that job needs a maintainer re-run (or it will re-run on the next push) to get a clean Windows confirmation.

@mikelehen
mikelehen force-pushed the fix-hoisted-link-destination-cwd-race branch from 5f10677 to e64f1c6 Compare August 4, 2026 21:26
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
pnpm11/building/during-install/test/hoistedLocations.test.ts (1)

23-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use asynchronous filesystem APIs in this asynchronous test.

Replace mkdtempSync, mkdirSync, writeFileSync, and rmSync with fs.promises calls. This keeps filesystem work non-blocking and follows the repository convention.

As per coding guidelines: “Prefer asynchronous filesystem APIs and async/await.”

Proposed change
-  const lockfileDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pnpm-hoisted-'))
+  const lockfileDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'pnpm-hoisted-'))
   try {
     await runInstall(lockfileDir)
   } finally {
-    fs.rmSync(lockfileDir, { recursive: true, force: true })
+    await fs.promises.rm(lockfileDir, { recursive: true, force: true })
   }
@@
-  fs.mkdirSync(pkgDir, { recursive: true })
-  fs.writeFileSync(path.join(pkgDir, 'package.json'), JSON.stringify({ name: 'foo', version: '1.0.0' }))
+  await fs.promises.mkdir(pkgDir, { recursive: true })
+  await fs.promises.writeFile(path.join(pkgDir, 'package.json'), JSON.stringify({ name: 'foo', version: '1.0.0' }))

Also applies to: 38-39

🤖 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/building/during-install/test/hoistedLocations.test.ts` around lines 23
- 27, Update the asynchronous test setup and cleanup around runInstall to use
fs.promises equivalents for mkdtemp, mkdir, writeFile, and rm, awaiting each
filesystem operation while preserving the existing temporary-directory lifecycle
and cleanup behavior.

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.

Nitpick comments:
In `@pnpm11/building/during-install/test/hoistedLocations.test.ts`:
- Around line 23-27: Update the asynchronous test setup and cleanup around
runInstall to use fs.promises equivalents for mkdtemp, mkdir, writeFile, and rm,
awaiting each filesystem operation while preserving the existing
temporary-directory lifecycle and cleanup behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c4f6e15-8a4d-4aaf-96b2-95d7e8899a23

📥 Commits

Reviewing files that changed from the base of the PR and between 0238477 and e64f1c6.

📒 Files selected for processing (3)
  • .changeset/absolute-hoisted-link-destinations.md
  • pnpm11/building/during-install/src/index.ts
  • pnpm11/building/during-install/test/hoistedLocations.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/absolute-hoisted-link-destinations.md
  • pnpm11/building/during-install/src/index.ts

…e main thread

`hardLinkDir()` runs on a worker thread but was handed destinations relative to
lockfileDir. The cwd is process-wide and shared with worker threads, and
`applyPatchToDir()` switches the cwd to the package it patches for the duration of
the patch. A worker resolving a relative destination inside that window resolved it
against the patched package instead of the project root, so the rename failed with
ERR_PNPM_ENOENT or ERR_PNPM_ENOTEMPTY.

Resolving the destinations on the main thread is safe because the cwd is only
switched inside a synchronous block, so no other main-thread code observes it. The
rebuild path already resolves `hoistedLocations` this way before calling
`hardLinkDir()`; this makes install consistent with it.

Closes pnpm#13627

Note pnpm#12880 shares the error text but is a distinct parent/child destination overlap
inside `hardLinkDir` itself, which this does not address.

Written by an agent (Claude Code, claude-opus-5).
… the fixture

The mock had no declared signature, so `mock.calls[0][1]` failed to typecheck under the
test tsconfig (TS2493). Declaring the signature also removes the need for a cast.

Remove the temporary project in a `finally` block so repeated runs stop accumulating
`pnpm-hoisted-*` directories in the system temporary directory.

Written by an agent (Claude Code, claude-opus-5).
…with path.join

The fixture hardcoded `node_modules/foo` with forward slashes, but the install code
matches the current location against `path.relative(lockfileDir, depNode.dir)`, which
uses backslashes on Windows. Nothing was filtered out there, so the test saw two
destinations instead of one and failed on the Windows CI matrix.

Real hoisted locations also come from `path.relative()`, so building the fixture's the
same way keeps it faithful to the data the install path actually receives.

Written by an agent (Claude Code, claude-opus-5).
@zkochan
zkochan force-pushed the fix-hoisted-link-destination-cwd-race branch from e64f1c6 to 53479ea Compare August 7, 2026 14:04
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
pnpm11/building/during-install/test/hoistedLocations.test.ts (2)

1-3: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use asynchronous filesystem APIs in this async test.

Lines 23-39 use synchronous fixture I/O although the test and runInstall() are asynchronous. Use promise-based filesystem APIs and await cleanup in finally.

As per coding guidelines, TypeScript code should prefer asynchronous filesystem APIs and async/await.

Proposed filesystem update
-import fs from 'node:fs'
+import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
 
-  const lockfileDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pnpm-hoisted-'))
+  const lockfileDir = await mkdtemp(path.join(os.tmpdir(), 'pnpm-hoisted-'))
   try {
     await runInstall(lockfileDir)
   } finally {
-    fs.rmSync(lockfileDir, { recursive: true, force: true })
+    await rm(lockfileDir, { recursive: true, force: true })
   }
 
-  fs.mkdirSync(pkgDir, { recursive: true })
-  fs.writeFileSync(path.join(pkgDir, 'package.json'), JSON.stringify({ name: 'foo', version: '1.0.0' }))
+  await mkdir(pkgDir, { recursive: true })
+  await writeFile(path.join(pkgDir, 'package.json'), JSON.stringify({ name: 'foo', version: '1.0.0' }))

Also applies to: 23-27, 37-39

🤖 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/building/during-install/test/hoistedLocations.test.ts` around lines 1
- 3, Update the asynchronous test and its fixture setup/cleanup to use
promise-based filesystem APIs from fs.promises, await directory creation and
removal, and ensure cleanup is awaited in the finally block while preserving the
existing runInstall() assertions.

Source: Coding guidelines


18-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the comments current and correct.

Replace the historical incident wording in Line 21 with the current worker/cwd invariant. Fix the grammatical error in Lines 32-34.

As per coding guidelines, comments must describe current non-obvious invariants rather than historical implementation details.

Proposed comment update
-// hardLinkDir() runs on a worker thread, and the cwd is process-wide: applyPatchToDir()
-// switches the cwd to the package it patches, so a worker resolving a relative
-// destination during that window resolves it against the wrong directory. That surfaced as
-// intermittent ERR_PNPM_ENOENT/ENOTEMPTY renames of `_tmp_*` under nodeLinker=hoisted.
+// Resolve hoisted destinations on the main thread because `hardLinkDir()` runs in a worker
+// and `applyPatchToDir()` can change the process-wide cwd.
 
-// Real hoisted locations come from path.relative(), so they use the platform's
-// separator. Build the fixture's the same way, otherwise on Windows the install code
-// cannot match the current location against them and filters nothing out.
+// `path.relative()` produces platform-specific separators. Use `path.join()` to match
+// the install code's `hoistedLocations` entries on Windows.

Also applies to: 32-34

🤖 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/building/during-install/test/hoistedLocations.test.ts` around lines 18
- 21, Update the comments around hardLinkDir() and applyPatchToDir() to state
the current worker-thread/process-wide cwd invariant and why relative paths must
not depend on the mutable cwd, removing historical incident details. Also
correct the grammatical error in the related comment at lines 32-34 while
preserving its intended meaning.

Sources: Coding guidelines, 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/building/during-install/test/hoistedLocations.test.ts`:
- Around line 1-3: Update the asynchronous test and its fixture setup/cleanup to
use promise-based filesystem APIs from fs.promises, await directory creation and
removal, and ensure cleanup is awaited in the finally block while preserving the
existing runInstall() assertions.
- Around line 18-21: Update the comments around hardLinkDir() and
applyPatchToDir() to state the current worker-thread/process-wide cwd invariant
and why relative paths must not depend on the mutable cwd, removing historical
incident details. Also correct the grammatical error in the related comment at
lines 32-34 while preserving its intended meaning.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d0dc84a2-7124-4200-88cd-affa45095d42

📥 Commits

Reviewing files that changed from the base of the PR and between 97f20b0 and 53479ea.

📒 Files selected for processing (3)
  • .changeset/absolute-hoisted-link-destinations.md
  • pnpm11/building/during-install/src/index.ts
  • pnpm11/building/during-install/test/hoistedLocations.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/absolute-hoisted-link-destinations.md
  • pnpm11/building/during-install/src/index.ts

@qodo-code-review

qodo-code-review Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Historical failure comment in test ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
A new comment explains the change using historical phrasing about how the bug "surfaced" as
intermittent errors, instead of documenting the current invariant/contract. This can become
misleading over time and violates the rule against historical implementation notes in source
comments.
Code

pnpm11/building/during-install/test/hoistedLocations.test.ts[R18-21]

+// hardLinkDir() runs on a worker thread, and the cwd is process-wide: applyPatchToDir()
+// switches the cwd to the package it patches, so a worker resolving a relative
+// destination during that window resolves it against the wrong directory. That surfaced as
+// intermittent ERR_PNPM_ENOENT/ENOTEMPTY renames of `_tmp_*` under nodeLinker=hoisted.
Relevance

●●● Strong

Recent precedent: team often rewrites comments to avoid historical phrasing and state current
invariants instead.

PR-#13383
PR-#13138
PR-#12954

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The comment at the test call site uses historical phrasing ("That surfaced as...") to describe past
failures, which the checklist disallows in inline comments. The cited rule requires comments to
describe current behavior rather than historical outcomes/implementations.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm11/building/during-install/test/hoistedLocations.test.ts[18-21]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A newly added comment uses historical phrasing ("That surfaced as...") rather than documenting the current behavior/invariant.

## Issue Context
Per compliance, comments should describe current behavior/contracts, not past implementations or historical outcomes.

## Fix Focus Areas
- pnpm11/building/during-install/test/hoistedLocations.test.ts[18-21]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider

Tip of the day
💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

…tionale in one place

The fixture now uses the fs.promises APIs, per the repo's preference for
asynchronous filesystem calls in async code.

The cwd-race rationale was spelled out twice, in buildDependency() and again
above the test. Comments document a shared why once at its common home, so the
source comment is now the single explanation and the test header points at it.
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 4f49f9b

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan
zkochan merged commit 4626752 into pnpm:main Aug 10, 2026
22 checks passed
@welcome

welcome Bot commented Aug 10, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

@mikelehen

Copy link
Copy Markdown
Contributor Author

Thank you! 🙏

absolutepraya added a commit to absolutepraya/marka that referenced this pull request Oct 16, 2026
## Problem and fix

The post-merge CI run for #130 failed twice with `ERR_PNPM_ENOENT` while
renaming a temporary directory into
`node_modules/astro/node_modules/tsx/node_modules/esbuild`. The first
attempt failed in the E2E Docker build; the retry failed in the shared
CI setup. Both failures blocked commit images and the automatic release,
leaving production on v0.9.0.

Pin pnpm 11.25.0 instead of 11.2.1. This is the first release containing
both relevant hoisted-install race fixes:

- [11.22.0](https://github.com/pnpm/pnpm/releases/tag/v11.22.0): resolve
hoisted copy destinations before worker threads can observe the
temporary `process.chdir()` used for patched dependencies ([upstream PR
#13646](pnpm/pnpm#13646)).
- [11.25.0](https://github.com/pnpm/pnpm/releases/tag/v11.25.0): stop
replacing parent destination directories when copying built packages to
other hoisted locations, which could delete nested dependency
directories during concurrent copies ([upstream issue
#12880](pnpm/pnpm#12880)).

Marka uses `nodeLinker: hoisted` and `patchedDependencies`. CI's
Corepack setup and Docker builds both honor the root `packageManager`
pin. Keep the runtime documentation and README badge consistent with
that pin.

No dependency versions or lockfile resolutions change. No cache purge,
install retries, suppressed lifecycle scripts, or runtime workaround is
introduced.

## Validation

- `pnpm install --frozen-lockfile` with pnpm 11.25.0 on macOS.
- `pnpm format:fix`, `pnpm lint`, and `pnpm typecheck`.
- `pnpm test:release-contract`.
- Four clean Linux amd64 installs passed: two each under Node 22.21.1
and Node 24.18.1. The second run on each version used an offline store.
Lifecycle scripts remained enabled; the nested `astro -> tsx -> esbuild`
dependency resolved after installation, and the lockfile checksum was
unchanged.

The race lives inside pnpm, so a repository unit test would not exercise
the failing seam. The upstream fixes include regression coverage;
validation here uses Marka's actual manifests, patches, lockfile,
hoisted layout, and enabled dependency lifecycle scripts. [GitHub CI
passed](https://github.com/absolutepraya/marka/actions/runs/38901394301),
including the complete E2E Docker build, at commit
`5ab104a01e52c525b276851adbff77116ae8b519`.

## LLM use

Diagnosed, implemented, and validated with Codex. Documentation
references to the package-manager version were updated alongside the
pin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hoisted hard-link destinations are resolved on a worker thread, so a patch's process.chdir breaks the rename

2 participants