Skip to content

fix(injected-deps-syncer): skip FIFOs when syncing injected deps - #13612

Closed
EduardoFernandess wants to merge 6 commits into
pnpm:mainfrom
EduardoFernandess:fix/13550-skip-fifo-inodes
Closed

EduardoFernandess wants to merge 6 commits into
pnpm:mainfrom
EduardoFernandess:fix/13550-skip-fifo-inodes

Conversation

@EduardoFernandess

@EduardoFernandess EduardoFernandess commented Aug 3, 2026 •

Copy link
Copy Markdown

Summary

Fixes #13550.

extendFilesMap threw UNSUPPORTED_INODE_TYPE when it encountered a FIFO, socket, or device node (for example a 1Password .env pipe next to package files). That aborted syncInjectedDepsAfterScripts and left injected copies stale.

Change

  • Map non-file/non-directory inodes to an UNSUPPORTED sentinel instead of throwing.
  • applyPatch never hardlinks UNSUPPORTED entries from the source (source-side FIFOs are ignored for materialisation).
  • Target-side specials still participate in the diff, so they can be removed or replaced when the source has a regular file at the same path (avoids EEXIST from linking over a FIFO).

Test plan

Summary by CodeRabbit

  • Bug Fixes

    • Improved directory synchronization for special filesystem entries such as FIFOs, sockets, and device nodes.
    • Correctly removes or replaces unsupported entries when the target contains a regular file or directory.
    • Prevented synchronization failures when encountering unsupported filesystem entry types.
    • Applies removals and modifications before additions for more reliable updates.
  • Tests

    • Added coverage for detecting unsupported entries, preserving regular files, and handling replacements in directory differences.

FIFOs and other non-file/dir nodes (e.g. 1Password `.env` pipes) caused
extendFilesMap to throw UNSUPPORTED_INODE_TYPE, aborting
syncInjectedDepsAfterScripts and leaving injected workspace deps stale.

Skip those inode types instead of failing the whole sync.

Fixes #13550

Co-authored-by: Cursor <[email protected]>
@welcome

welcome Bot commented Aug 3, 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.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@EduardoFernandess, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 30 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 43325945-168f-41a3-a46e-0e482c693485

📥 Commits

Reviewing files that changed from the base of the PR and between e980d0d and ada3f55.

📒 Files selected for processing (2)
  • pnpm11/workspace/injected-deps-syncer/test/diffDir.test.ts
  • pnpm11/workspace/injected-deps-syncer/test/extendFilesMap.test.ts
📝 Walkthrough

Walkthrough

DirPatcher records unsupported inode types instead of throwing, skips their materialization, and preserves them in diffs for target cleanup or replacement. Tests cover FIFO detection and unsupported-to-file replacement.

Changes

Inode synchronization

Layer / File(s) Summary
Record unsupported inode types
pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts, pnpm11/workspace/injected-deps-syncer/test/DirPatcher.test.ts, pnpm11/workspace/injected-deps-syncer/test/extendFilesMap.test.ts, cspell.json
DirPatcher adds the UNSUPPORTED marker and records FIFOs, sockets, and device nodes. Tests verify supported inode values and unsupported markers.
Preserve unsupported diffs
pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts, pnpm11/workspace/injected-deps-syncer/test/diffDir.test.ts
Patch application skips materializing unsupported source entries and processes removals and modifications before additions. Diff tests verify unsupported-to-file changes remain modified entries.

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

Assessment against linked issues

Objective Addressed Explanation
Do not fail when a FIFO is outside the package’s declared files; exclude or safely skip unsupported inode types [#13550] ✅

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.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix injected deps sync by skipping FIFO/unsupported inode types

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Prevent injected dependency sync from failing on FIFOs/sockets/device nodes in source trees.
• Treat non-file/non-directory entries as ignorable during injected package directory walks.
• Add a unit test ensuring FIFOs are omitted while regular files are still synced.
Diagram

graph TD
  A["syncInjectedDepsAfterScripts"] --> B["extendFilesMap (DirPatcher)"] --> C[("Filesystem")]
  C --> D["Injected package dir"] --> E{File or dir?}
  E -->|"yes"| F[/"inode/files map"/] --> A
  E -->|"no"| G["Skip FIFO/socket/device"]

  subgraph Legend
    direction LR
    _fn["Function"] ~~~ _fs[("Filesystem")] ~~~ _dec{Decision} ~~~ _out[/"Output"/]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Warn-and-continue (rather than silent skip)
  • ➕ Preserves resilience while surfacing surprising filesystem entries to users
  • ➕ Easier to diagnose why some paths were omitted from the sync
  • ➖ Could add noise for users who intentionally have FIFOs (e.g., env pipes)
  • ➖ Requires deciding logging surface (debug vs. normal output) and message wording
2. Handle filtering at the sync entrypoint instead of extendFilesMap
  • ➕ Keeps extendFilesMap strict, limiting behavior change scope
  • ➕ Allows different callers to choose strict vs. tolerant behavior
  • ➖ Risk of duplicated inode-type handling across callers
  • ➖ Less robust if other call sites also traverse injected dirs and hit FIFOs

Recommendation: The chosen approach (skipping unsupported inode types inside extendFilesMap) is the most robust because it hardens the shared directory-walk primitive and prevents injected-deps sync from failing on common special nodes like FIFOs. If maintainers want more observability, consider adding an opt-in debug log or counter for skipped entries without reintroducing hard failures.

Files changed (2) +28 / -3

Bug fix (1) +3 / -3
DirPatcher.tsSkip unsupported inode types during directory walk to avoid aborting sync +3/-3

Skip unsupported inode types during directory walk to avoid aborting sync

• Removes the hard failure when encountering filesystem entries that are neither files nor directories. Unsupported inode types (e.g., FIFOs used for env pipes) are now ignored so injected dependency sync can proceed and keep regular files up to date.

pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts

Tests (1) +25 / -0
DirPatcher.test.tsAdd unit test to ensure FIFOs are omitted from extendFilesMap results +25/-0

Add unit test to ensure FIFOs are omitted from extendFilesMap results

• Adds a test that creates a FIFO (when supported) and verifies extendFilesMap returns an inode for a regular file but omits the FIFO path. The test gracefully skips on platforms/environments where mkfifo is unavailable.

pnpm11/workspace/injected-deps-syncer/test/DirPatcher.test.ts

@greptile-apps

greptile-apps Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; current code removes target special inodes before replacement and completes parent modifications before adding descendant files.

Reviews (6): Last reviewed commit: "style: correct UNSUPPORTED import order ..." | Re-trigger Greptile

Record FIFOs/sockets/devices as UNSUPPORTED so target-side specials can
be removed or replaced, and never hardlink them from the source. Fixes
the TypeScript test that incorrectly called non-existent fs.mkfifoSync.

Co-authored-by: Cursor <[email protected]>

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts`:
- Around line 158-161: Add release metadata for the change around DirPatcher’s
special-file skipping logic: create a concise changeset with an explicit pnpm
patch bump, and add the corresponding Pacquet changeset or document why Pacquet
parity is deferred.

In `@pnpm11/workspace/injected-deps-syncer/test/DirPatcher.test.ts`:
- Around line 229-236: Update the FIFO setup around fs.mkfifoSync so
process.platform === 'win32' returns before attempting creation; otherwise catch
errors and ignore only the documented unsupported-operation codes (ENOSYS and
EPERM), rethrowing every other error instead of allowing the platform check to
swallow it.
🪄 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: ad359fcd-fb0a-4e15-9908-d0793d030fe0

📥 Commits

Reviewing files that changed from the base of the PR and between a937480 and b99742c.

📒 Files selected for processing (2)
  • pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts
  • pnpm11/workspace/injected-deps-syncer/test/DirPatcher.test.ts

Comment on lines +158 to +161
}
// Skip FIFOs, sockets, and device nodes (e.g. 1Password `.env` pipes).
// Throwing here aborted syncInjectedDepsAfterScripts and left injected
// deps stale — see https://github.com/pnpm/pnpm/issues/13550.

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== files =="
git ls-files | rg '(^|/)changesets?/|DirPatcher\.ts$|Pacquet|package\.json$|changeset\.config|pnpm|README|AGENTS|CONTRIBUTING|REVIEW_GUIDE' || true

echo "== DirPatcher relevant section =="
sed -n '130,175p' pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts

echo "== changeset files =="
if [ -d .changeset ]; then find .changeset -maxdepth 1 -type f -print0 | xargs -0 -r -n1 sh -c 'echo "--- $0"; sed -n "1,80p" "$0"'; fi

echo "== changeset/config refs =="
rg -n "changesets|changeset|Pacquet|pnpm|patch|release" -S . --glob '!node_modules' --glob '!dist' | head -200

Repository: pnpm/pnpm

Length of output: 50368


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== DirPatcher full file outline/contents stat =="
wc -l pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts
cat -n pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts

echo "== changesets mentioning injected, Pipe, FIFO, DirPatcher, Pacquet injected =="
rg -n "injected|DirPatcher|Pacquet|pip|FIFO|socket|device|cat|patch|1Password|13550|syncInjectedDepsAfterScripts" .changeset --glob '*.md' || true

echo "== package references for DirPatcher module =="
rg -n "`@pnpm/injected-deps-syncer`|DirPatcher|extendFilesMap|InodeMap|applyPatch" pnpm11 pnpm -S --glob '!**/pnpm-lock.yaml' | head -250

Repository: pnpm/pnpm

Length of output: 50365


Add the required release metadata for the injected dependency sync change.

Add a concise changeset that includes an explicit pnpm patch bump. Add the matching Pacquet changeset or record why Pacquet parity is deferred.

🤖 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/workspace/injected-deps-syncer/src/DirPatcher.ts` around lines 158 -
161, Add release metadata for the change around DirPatcher’s special-file
skipping logic: create a concise changeset with an explicit pnpm patch bump, and
add the corresponding Pacquet changeset or document why Pacquet parity is
deferred.

Source: Path instructions

Comment on lines +229 to +236
try {
fs.mkfifoSync(fifoPath)
} catch (err) {
// Windows and some CI images lack mkfifo — skip rather than fail.
if ((err as NodeJS.ErrnoException).code === 'ENOSYS' || (err as NodeJS.ErrnoException).code === 'EPERM' || process.platform === 'win32') {
return
}
throw err

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Do not skip every Windows setup error.

The platform check is inside catch, so every Windows error becomes a passing test. Check process.platform before calling the FIFO creator. Then ignore only documented unsupported-operation codes and rethrow all other errors.

Suggested control flow
+  if (process.platform === 'win32') {
+    return
+  }
   try {
     fs.mkfifoSync(fifoPath)
   } catch (err) {
-    if (code === 'ENOSYS' || code === 'EPERM' || process.platform === 'win32') {
+    if (code === 'ENOSYS' || code === 'EPERM') {
       return
     }

As per coding guidelines, catch only the specific expected error code and do not broadly swallow errors.

🤖 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/workspace/injected-deps-syncer/test/DirPatcher.test.ts` around lines
229 - 236, Update the FIFO setup around fs.mkfifoSync so process.platform ===
'win32' returns before attempting creation; otherwise catch errors and ignore
only the documented unsupported-operation codes (ENOSYS and EPERM), rethrowing
every other error instead of allowing the platform check to swallow it.

Source: Coding guidelines

@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/workspace/injected-deps-syncer/src/DirPatcher.ts`:
- Around line 164-168: Update the comment in DirPatcher’s unsupported-entry
handling to remove the historical failure explanation and issue link. Keep only
the invariant that unsupported entries remain in the diff so target-side special
entries can be removed or replaced, while never being materialized from the
source by applyPatch.
🪄 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: 0f0262df-b980-4935-a122-aadf17aee478

📥 Commits

Reviewing files that changed from the base of the PR and between b99742c and dc88049.

📒 Files selected for processing (4)
  • pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts
  • pnpm11/workspace/injected-deps-syncer/test/DirPatcher.test.ts
  • pnpm11/workspace/injected-deps-syncer/test/diffDir.test.ts
  • pnpm11/workspace/injected-deps-syncer/test/extendFilesMap.test.ts

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. Concurrent patch ordering race 🐞 Bug ☼ Reliability ⭐ New
Description
applyPatch runs added and modified operations concurrently, so when a target path is
UNSUPPORTED (FIFO/socket/device) and the source turns it into a directory with children, a child
add may attempt to create/link under that path before the parent replacement completes and fail
(e.g. ENOTDIR/EEXIST), aborting the sync. This becomes reachable because extendFilesMap now records
special inodes as UNSUPPORTED instead of throwing.
Code

pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[R166-169]

+      // applyPatch never hardlinks these from the source.
+      // Throwing here aborted syncInjectedDepsAfterScripts and left injected
+      // deps stale — see https://github.com/pnpm/pnpm/issues/13550.
+      addInodeAndAncestors(relativePath, UNSUPPORTED)
Relevance

●● Moderate

No close historical matches found for applyPatch add/modify ordering races; unclear if team
prioritizes fixing this edge case now.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
extendFilesMap now maps non-file/non-directory stats to the UNSUPPORTED sentinel, so a target-side
FIFO can participate as an existing path in the diff (producing a parent modified entry) rather
than aborting early. applyPatch then starts adding and modifying concurrently, and the added
file path handler uses mkdirSync(path.dirname(targetPath), { recursive: true }), which can fail if
the parent path still exists as a special inode because the parent replacement is happening in
parallel.

pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[85-129]
pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[150-171]

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

## Issue description
`extendFilesMap()` now records special inode types as `UNSUPPORTED`, which allows diffs where a parent path is a `ModifiedItem` (e.g. `UNSUPPORTED -> DIR`) and its children are `AddedItem`s. `applyPatch()` currently applies `added`, `removed`, and `modified` in parallel; this can race such that a child `added` item runs before the parent `modified` item has removed/recreated the parent path, causing filesystem errors (commonly `ENOTDIR`/`EEXIST`) and aborting injected-deps sync.

## Issue Context
This is most likely when the *target* has a FIFO/socket/device at `pipe` and the *source* has a real directory `pipe/` containing files. The diff will include:
- `modified: [{ path: 'pipe', oldValue: UNSUPPORTED, newValue: DIR }]`
- `added: [{ path: 'pipe/file.txt', newValue: <inode> }, ...]`
The `added` handler calls `mkdirSync(path.dirname(targetPath), { recursive: true })`, which fails if `pipe` is still a FIFO.

## Fix Focus Areas
- pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[85-129]
- pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[145-171]

### Suggested fix approach
1. Change `applyPatch()` to enforce a safe phase order for type-changing parents:
  - Phase 1: execute `removed` (already reversed) and the **remove** portion of `modified` (i.e., `removeRecursive(targetPath)` for each modified item).
  - Phase 2: execute the **add** portion of `modified` (i.e., `addRecursive(...)` for each modified item).
  - Phase 3: execute `added`.
  This ensures parent replacements (like `UNSUPPORTED -> DIR`) complete before any child additions attempt to create/link beneath them.
2. Add a regression test that constructs:
  - Source: `pipe/child.txt` (a real directory with a file)
  - Target: `pipe` as a FIFO (or a mocked stat + filesystem layer)
  and asserts `DirPatcher.apply()` succeeds and materializes the expected directory/file on target.

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



Remediation recommended

2. Jest test silently returns early 📘 Rule violation ▣ Testability ⭐ New
Description
The new FIFO test effectively skips (passes) via early return on Windows and when mkfifo is
unavailable, which can mask coverage gaps without an explicit quarantine reference. This conflicts
with the requirement to avoid newly skipping/ignoring tests without a tracked justification.
Code

pnpm11/workspace/injected-deps-syncer/test/DirPatcher.test.ts[R235-237]

+  } catch {
+    // Some CI images lack mkfifo — skip rather than fail.
+    return
Relevance

●● Moderate

No strong historical evidence on banning early-return “skips”; team sometimes improves test
robustness, but this pattern isn’t documented.

PR-#13074

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The compliance checklist disallows newly skipping/ignoring tests without an explicit issue reference
and justification. The added test exits early (passing) on certain platforms/environments, which is
functionally a skip without being tracked as such.

Rule 713440: Investigate and resolve all failing tests before merge
pnpm11/workspace/injected-deps-syncer/test/DirPatcher.test.ts[225-238]

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 test case is conditionally bypassed by `return`, making it appear as a pass (not a skip) when `mkfifo` is missing or on Windows.

## Issue Context
The compliance rule requires failing tests to be resolved and discourages introducing skipped/ignored tests without an explicit issue reference and justification.

## Fix Focus Areas
- pnpm11/workspace/injected-deps-syncer/test/DirPatcher.test.ts[225-238]

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


3. UNSUPPORTED creates empty dirs 🐞 Bug ➹ Performance
Description
extendFilesMap records UNSUPPORTED entries via addInodeAndAncestors(), which also records every
ancestor directory as DIR; applyPatch then mkdirs those ancestors but never materializes the
UNSUPPORTED leaf. Because fetchFromDir/filesMap does not record directories (and therefore
extendFilesMap cannot “see” empty dirs on the next run), syncInjectedDeps can produce a non-empty
diff forever and repeatedly traverse/mkdir those paths on every configured script run.
Code

pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[R166-169]

+      // applyPatch never hardlinks these from the source.
+      // Throwing here aborted syncInjectedDepsAfterScripts and left injected
+      // deps stale — see https://github.com/pnpm/pnpm/issues/13550.
+      addInodeAndAncestors(relativePath, UNSUPPORTED)
Relevance

●● Moderate

No historical suggestions found about UNSUPPORTED/empty-dir perpetual diffs; file history lookup for
DirPatcher.ts failed.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new behavior is introduced by recording UNSUPPORTED via addInodeAndAncestors, which recursively
inserts DIR ancestors; applyPatch then creates those directories but skips the UNSUPPORTED leaf. The
directory fetcher only adds non-directory entries to filesMap, so empty dirs created solely due to
UNSUPPORTED leaves are not represented on the next run, leading to repeated diffs/mkdir attempts.

pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[150-170]
pnpm11/fetching/directory-fetcher/src/index.ts[83-103]

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

## Issue description
`extendFilesMap()` currently calls `addInodeAndAncestors(relativePath, UNSUPPORTED)`, which unconditionally adds ancestor directories as `DIR`. Since `applyPatch()` intentionally does not materialize `UNSUPPORTED` leaves, this can create empty directories on targets.

Because `fetchFromDir()`/`filesMap` only tracks non-directory entries, those empty directories are not represented in subsequent inode maps, so the next `syncInjectedDeps` run will keep generating “added” directory entries and keep re-running `mkdir(..., { recursive: true })` + directory traversal.

## Issue Context
This is triggered when a package contains an unsupported inode under a directory that otherwise has no regular files (e.g. `secrets/pipe.env` is a FIFO and `secrets/` has no other files).

## Fix Focus Areas
- pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[150-170]

### Suggested approach
- When encountering an unsupported inode, record **only the leaf path** as `UNSUPPORTED` (do not add ancestor `DIR` entries for it), since the leaf will never be materialized.
- Ensure behavior remains correct for:
 - target special -> source file replacement (still a `modified` leaf)
 - target file -> source unsupported (still removes leaf)
- Add a regression unit test for an UNSUPPORTED entry nested under an otherwise-empty directory to ensure ancestors are not emitted (or that repeated sync produces no extra mkdir work).

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


4. Historical comment in extendFilesMap 📘 Rule violation ⚙ Maintainability
Description
A newly added inline comment describes past behavior ("Throwing here aborted...") rather than the
current contract. This creates stale documentation risk and violates the guideline to avoid
historical implementation commentary in source comments.
Code

pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[R167-168]

+      // Throwing here aborted syncInjectedDepsAfterScripts and left injected
+      // deps stale — see https://github.com/pnpm/pnpm/issues/13550.
Relevance

●● Moderate

Team sometimes accepts rewriting historical comments (PRs #13559, #13594) but also rejects similar
requests elsewhere.

PR-#13559
PR-#13594
PR-#13234

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The added comment uses historical phrasing about prior throwing behavior ("Throwing here
aborted...") rather than documenting the current behavior/contract, which is disallowed by the
checklist rule.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[164-169]

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 new comment in `extendFilesMap` uses historical phrasing ("Throwing here aborted...") describing prior behavior instead of stating the current contract/intent.

## Issue Context
Compliance requires comments to describe current behavior, invariants, and rationale without historical narration.

## Fix Focus Areas
- pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[164-169]

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



Informational

5. Pacquet FIFO handling not synced 📘 Rule violation ⌂ Architecture ⭐ New
Description
This PR changes pnpm TypeScript behavior to tolerate special inode types (e.g. FIFOs) by tracking
them as UNSUPPORTED and never materializing/hardlinking them. There is no corresponding pacquet
(Rust) change shown here, so user-visible behavior may diverge unless pacquet is updated or the
divergence is explicitly called out.
Code

pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[R89-90]

+    } else if (value === UNSUPPORTED) {
+      // Source-side special inodes are intentionally not materialized on the target.
Relevance

● Weak

Similar “call out pnpm↔pacquet divergence” suggestion was rejected in PR #13594; parity drift notes
not enforced.

PR-#13594
PR-#13463

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The checklist requires syncing user-visible behavior changes between pnpm (TS) and pacquet (Rust).
The PR adds UNSUPPORTED handling in pnpm’s injected-deps syncer, while pacquet’s directory walker
inserts any non-directory entry into its files map (which would include FIFOs/sockets/device nodes),
indicating the two implementations may now differ.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[86-93]
pnpm/crates/directory-fetcher/src/walker.rs[125-135]

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

## Issue description
pnpm TypeScript now treats FIFOs/sockets/device nodes as `UNSUPPORTED` and avoids hardlink/materialization, but pacquet’s directory walking still appears to treat any non-directory entry as a file path, which can lead to behavior divergence.

## Issue Context
Compliance requires pnpm TypeScript and pacquet Rust user-visible behavior to stay in sync, or for the PR to explicitly call out the known divergence.

## Fix Focus Areas
- pnpm/crates/directory-fetcher/src/walker.rs[125-135]
- pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[86-93]

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


6. Missing changeset for published package 📘 Rule violation § Compliance
Description
This PR changes code in the published package @pnpm/workspace.injected-deps-syncer but does not
include an accompanying changeset entry. Without a changeset, the release process may omit this
user-visible bug fix from versioning and changelogs.
Code

pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[R8-9]

+/** FIFO, socket, device node, etc. — tracked so targets can be cleaned up, never hardlinked. */
+export const UNSUPPORTED: unique symbol = Symbol('Unsupported inode type')
Relevance

● Weak

Similar “missing changeset” requests were rejected (e.g. PR #12441); changeset enforcement appears
inconsistent.

PR-#12441
PR-#11481
PR-#12931

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The diff changes runtime logic in @pnpm/workspace.injected-deps-syncer (e.g., introducing
UNSUPPORTED handling), and the package is published (has a package name/version and no `private:
true`), so a changeset is required by the checklist rule.

Rule 713441: Require changeset for TypeScript package changes
pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[7-17]
pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[145-170]
pnpm11/workspace/injected-deps-syncer/package.json[1-25]

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 published TypeScript package was modified without adding a `.changeset/*.md` file to declare the release note and bump type.

## Issue Context
`pnpm11/workspace/injected-deps-syncer` is a published package (`@pnpm/workspace.injected-deps-syncer`). The change alters runtime behavior (handling of special inode types) and should be released as a `patch`.

## Fix Focus Areas
- pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[8-15]
- pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[157-170]
- pnpm11/workspace/injected-deps-syncer/package.json[1-21]
- .changeset/*[1-20]

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


Grey Divider

ⓘ  1 issues published inline · 3 in summary

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Previous review results

Review updated until commit 7350e95 ⚖️ Balanced

Results up to commit 7350e95 ⚖️ Balanced


🐞 Bugs (1) 📘 Rule violations (2) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Historical comment in extendFilesMap 📘 Rule violation ⚙ Maintainability
Description
A newly added inline comment describes past behavior ("Throwing here aborted...") rather than the
current contract. This creates stale documentation risk and violates the guideline to avoid
historical implementation commentary in source comments.
Code

pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[R167-168]

+      // Throwing here aborted syncInjectedDepsAfterScripts and left injected
+      // deps stale — see https://github.com/pnpm/pnpm/issues/13550.
Relevance

●● Moderate

Team sometimes accepts rewriting historical comments (PRs #13559, #13594) but also rejects similar
requests elsewhere.

PR-#13559
PR-#13594
PR-#13234

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The added comment uses historical phrasing about prior throwing behavior ("Throwing here
aborted...") rather than documenting the current behavior/contract, which is disallowed by the
checklist rule.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[164-169]

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 new comment in `extendFilesMap` uses historical phrasing ("Throwing here aborted...") describing prior behavior instead of stating the current contract/intent.

## Issue Context
Compliance requires comments to describe current behavior, invariants, and rationale without historical narration.

## Fix Focus Areas
- pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[164-169]

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


2. UNSUPPORTED creates empty dirs 🐞 Bug ➹ Performance
Description
extendFilesMap records UNSUPPORTED entries via addInodeAndAncestors(), which also records every
ancestor directory as DIR; applyPatch then mkdirs those ancestors but never materializes the
UNSUPPORTED leaf. Because fetchFromDir/filesMap does not record directories (and therefore
extendFilesMap cannot “see” empty dirs on the next run), syncInjectedDeps can produce a non-empty
diff forever and repeatedly traverse/mkdir those paths on every configured script run.
Code

pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[R166-169]

+      // applyPatch never hardlinks these from the source.
+      // Throwing here aborted syncInjectedDepsAfterScripts and left injected
+      // deps stale — see https://github.com/pnpm/pnpm/issues/13550.
+      addInodeAndAncestors(relativePath, UNSUPPORTED)
Relevance

●● Moderate

No historical suggestions found about UNSUPPORTED/empty-dir perpetual diffs; file history lookup for
DirPatcher.ts failed.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new behavior is introduced by recording UNSUPPORTED via addInodeAndAncestors, which recursively
inserts DIR ancestors; applyPatch then creates those directories but skips the UNSUPPORTED leaf. The
directory fetcher only adds non-directory entries to filesMap, so empty dirs created solely due to
UNSUPPORTED leaves are not represented on the next run, leading to repeated diffs/mkdir attempts.

pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[150-170]
pnpm11/fetching/directory-fetcher/src/index.ts[83-103]

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

## Issue description
`extendFilesMap()` currently calls `addInodeAndAncestors(relativePath, UNSUPPORTED)`, which unconditionally adds ancestor directories as `DIR`. Since `applyPatch()` intentionally does not materialize `UNSUPPORTED` leaves, this can create empty directories on targets.

Because `fetchFromDir()`/`filesMap` only tracks non-directory entries, those empty directories are not represented in subsequent inode maps, so the next `syncInjectedDeps` run will keep generating “added” directory entries and keep re-running `mkdir(..., { recursive: true })` + directory traversal.

## Issue Context
This is triggered when a package contains an unsupported inode under a directory that otherwise has no regular files (e.g. `secrets/pipe.env` is a FIFO and `secrets/` has no other files).

## Fix Focus Areas
- pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[150-170]

### Suggested approach
- When encountering an unsupported inode, record **only the leaf path** as `UNSUPPORTED` (do not add ancestor `DIR` entries for it), since the leaf will never be materialized.
- Ensure behavior remains correct for:
 - target special -> source file replacement (still a `modified` leaf)
 - target file -> source unsupported (still removes leaf)
- Add a regression unit test for an UNSUPPORTED entry nested under an otherwise-empty directory to ensure ancestors are not emitted (or that repeated sync produces no extra mkdir work).

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



Informational
3. Missing changeset for published package 📘 Rule violation § Compliance
Description
This PR changes code in the published package @pnpm/workspace.injected-deps-syncer but does not
include an accompanying changeset entry. Without a changeset, the release process may omit this
user-visible bug fix from versioning and changelogs.
Code

pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[R8-9]

+/** FIFO, socket, device node, etc. — tracked so targets can be cleaned up, never hardlinked. */
+export const UNSUPPORTED: unique symbol = Symbol('Unsupported inode type')
Relevance

● Weak

Similar “missing changeset” requests were rejected (e.g. PR #12441); changeset enforcement appears
inconsistent.

PR-#12441
PR-#11481
PR-#12931

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The diff changes runtime logic in @pnpm/workspace.injected-deps-syncer (e.g., introducing
UNSUPPORTED handling), and the package is published (has a package name/version and no `private:
true`), so a changeset is required by the checklist rule.

Rule 713441: Require changeset for TypeScript package changes
pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[7-17]
pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[145-170]
pnpm11/workspace/injected-deps-syncer/package.json[1-25]

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 published TypeScript package was modified without adding a `.changeset/*.md` file to declare the release note and bump type.

## Issue Context
`pnpm11/workspace/injected-deps-syncer` is a published package (`@pnpm/workspace.injected-deps-syncer`). The change alters runtime behavior (handling of special inode types) and should be released as a `patch`.

## Fix Focus Areas
- pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[8-15]
- pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[157-170]
- pnpm11/workspace/injected-deps-syncer/package.json[1-21]
- .changeset/*[1-20]

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


Qodo Logo

Apply removals/modifications before adds so replacing a special inode
with a directory cannot delete newly linked children. Keep mkfifo in
alphabetical order for meta-updater.

Co-authored-by: Cursor <[email protected]>
Comment on lines +166 to +169
// applyPatch never hardlinks these from the source.
// Throwing here aborted syncInjectedDepsAfterScripts and left injected
// deps stale — see https://github.com/pnpm/pnpm/issues/13550.
addInodeAndAncestors(relativePath, UNSUPPORTED)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

3. Concurrent patch ordering race 🐞 Bug ☼ Reliability

applyPatch runs added and modified operations concurrently, so when a target path is
UNSUPPORTED (FIFO/socket/device) and the source turns it into a directory with children, a child
add may attempt to create/link under that path before the parent replacement completes and fail
(e.g. ENOTDIR/EEXIST), aborting the sync. This becomes reachable because extendFilesMap now records
special inodes as UNSUPPORTED instead of throwing.
Agent Prompt
## Issue description
`extendFilesMap()` now records special inode types as `UNSUPPORTED`, which allows diffs where a parent path is a `ModifiedItem` (e.g. `UNSUPPORTED -> DIR`) and its children are `AddedItem`s. `applyPatch()` currently applies `added`, `removed`, and `modified` in parallel; this can race such that a child `added` item runs before the parent `modified` item has removed/recreated the parent path, causing filesystem errors (commonly `ENOTDIR`/`EEXIST`) and aborting injected-deps sync.

## Issue Context
This is most likely when the *target* has a FIFO/socket/device at `pipe` and the *source* has a real directory `pipe/` containing files. The diff will include:
- `modified: [{ path: 'pipe', oldValue: UNSUPPORTED, newValue: DIR }]`
- `added: [{ path: 'pipe/file.txt', newValue: <inode> }, ...]`
The `added` handler calls `mkdirSync(path.dirname(targetPath), { recursive: true })`, which fails if `pipe` is still a FIFO.

## Fix Focus Areas
- pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[85-129]
- pnpm11/workspace/injected-deps-syncer/src/DirPatcher.ts[145-171]

### Suggested fix approach
1. Change `applyPatch()` to enforce a safe phase order for type-changing parents:
   - Phase 1: execute `removed` (already reversed) and the **remove** portion of `modified` (i.e., `removeRecursive(targetPath)` for each modified item).
   - Phase 2: execute the **add** portion of `modified` (i.e., `addRecursive(...)` for each modified item).
   - Phase 3: execute `added`.
   This ensures parent replacements (like `UNSUPPORTED -> DIR`) complete before any child additions attempt to create/link beneath them.
2. Add a regression test that constructs:
   - Source: `pipe/child.txt` (a real directory with a file)
   - Target: `pipe` as a FIFO (or a mocked stat + filesystem layer)
   and asserts `DirPatcher.apply()` succeeds and materializes the expected directory/file on target.

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 7350e95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

syncInjectedDepsAfterScripts fails on a FIFO outside package files and leaves the injected dependency stale

1 participant