Skip to content

Revert "perf: do not canonicalize the entry path (#848)" - #204

Merged
JounQin merged 2 commits into
mainfrom
fix/symlink-with-nested-node_modules
May 19, 2026
Merged

JounQin merged 2 commits into
mainfrom
fix/symlink-with-nested-node_modules

Conversation

@JounQin

@JounQin JounQin commented May 19, 2026 •

Copy link
Copy Markdown
Member

This reverts commit ea425f6.

Summary by CodeRabbit

  • Bug Fixes

    • Improved path resolution handling for symlinked directories with nested dependencies, with conditional normalization based on symlink configuration.
  • Tests

    • Added test coverage for symlink resolution scenarios with nested modules.
    • Updated Windows symlink path handling tests.
  • Chores

    • Updated fixture gitignore configuration.

Review Change Stack

Copilot AI review requested due to automatic review settings May 19, 2026 02:56
@coderabbitai

coderabbitai Bot commented May 19, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@JounQin has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 35 minutes and 28 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d6c3eb57-f157-46ed-bc8d-ca6fd2bb1f35

📥 Commits

Reviewing files that changed from the base of the PR and between 12b0e59 and 4a0224a.

📒 Files selected for processing (3)
  • .node-version
  • src/lib.rs
  • vite.config.mts
📝 Walkthrough

Walkthrough

This PR implements conditional realpath normalization in the module resolver based on a symlinks configuration option, validates the fix through new test coverage for nested node_modules scenarios, updates Windows-specific DOS device path test expectations, and removes debug logging.

Changes

Symlink Resolution with Conditional Realpath Normalization

Layer / File(s) Summary
Conditional realpath normalization in resolve_impl
src/lib.rs
ResolverGeneric::resolve_impl now branches on self.options.symlinks: when enabled, the input path is realpaths before require and the result is realpaths before returning; when disabled, the cached path is returned directly without realpath operations.
Test coverage for symlink with nested node_modules
src/tests/resolve.rs
New symlink_with_nested_node_modules test verifies that resolving a dependency through a symlinked directory with nested node_modules succeeds when symlink handling is enabled and fails with ResolveError::NotFound when symlinks: false.
Windows DOS device path test updates
src/tests/symlink.rs
test_unsupported_targets now discards the unused root fixture binding while keeping temp_path, and updates the unsupported-path assertion to expect ResolveError::PathNotSupported(dos_device_temp_path) with the direct temp path instead of a root-derived device path.
Test and fixture cleanup
fixtures/pnp/index.test.mjs, fixtures/symlink-with-nested-node_modules/.gitignore
Removed console.log(resolution) debug statement from the PnP resolver test and added .gitignore rule to exclude !node_modules from fixture tracking.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • unrs/unrs-resolver#125: Introduces the same symlink-with-nested-node_modules resolution fix and test case.
  • unrs/unrs-resolver#86: Introduces the PathNotSupported(PathBuf) error variant and Windows DOS device prefix handling that this PR's test updates depend on.
  • unrs/unrs-resolver#100: Updates the same Windows symlink test (test_unsupported_targets) expectations around DOS device path handling.

Suggested labels

bug

Poem

🐰 Symlinks and paths all tangled up,
Realpath logic fills the cup,
When symlinks dance, we normalize,
When they don't, paths stay as-is,
Nested modules now find their way,
Resolution works to save the day! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly indicates the PR reverts a specific commit (#848) and is directly reflected in the code changes (conditional path normalization logic added to handle symlinks).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/symlink-with-nested-node_modules

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 and usage tips.

@codacy-production

codacy-production Bot commented May 19, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented May 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.11%. Comparing base (62ff4da) to head (4a0224a).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #204   +/-   ##
=======================================
  Coverage   93.11%   93.11%           
=======================================
  Files          21       21           
  Lines        4082     4083    +1     
=======================================
+ Hits         3801     3802    +1     
  Misses        281      281           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@fixtures/symlink-with-nested-node_modules/.gitignore`:
- Line 1: Replace the negated gitignore pattern "!node_modules" with an
excluding pattern "node_modules/" in the .gitignore (replace the literal string
'!node_modules' in fixtures/symlink-with-nested-node_modules/.gitignore with
'node_modules/') so that fixture dependency directories are properly ignored
rather than being unignored.

In `@src/lib.rs`:
- Around line 332-336: The current else branch returns cached_path.to_path_buf()
which skips self.load_realpath and therefore misses Windows separator
normalization; change the logic so that even when self.options.symlinks is false
you still pass cached_path through self.load_realpath (e.g., call
self.load_realpath(&cached_path)? for the final path used to populate
Resolution.path) to preserve cross-platform path separator normalization while
keeping the symlink behavior consistent.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 36c4780e-0fc7-4175-98fb-3fee59ebef6e

📥 Commits

Reviewing files that changed from the base of the PR and between 00dd8d6 and 12b0e59.

⛔ Files ignored due to path filters (3)
  • fixtures/symlink-with-nested-node_modules/bar/node_modules/foo is excluded by !**/node_modules/**
  • fixtures/symlink-with-nested-node_modules/foo/node_modules/dep/index.js is excluded by !**/node_modules/**
  • fixtures/symlink-with-nested-node_modules/foo/node_modules/foo/index.js is excluded by !**/node_modules/**
📒 Files selected for processing (5)
  • fixtures/pnp/index.test.mjs
  • fixtures/symlink-with-nested-node_modules/.gitignore
  • src/lib.rs
  • src/tests/resolve.rs
  • src/tests/symlink.rs
💤 Files with no reviewable changes (1)
  • fixtures/pnp/index.test.mjs

Comment thread src/lib.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Reverts the earlier performance change that avoided canonicalizing the entry path, restoring realpath/canonicalization behavior for symlink resolution and adjusting/adding tests and fixtures to cover nested node_modules behavior under symlinks.

Changes:

  • Restore entry-path canonicalization when ResolveOptions::symlinks is enabled, and adjust returned resolution path behavior accordingly.
  • Update Windows-specific symlink test expectations around unsupported DOS device paths.
  • Add an integration test + fixture for resolving dependencies from a symlinked package with nested node_modules; remove stray logging from the PnP fixture test.

Reviewed changes

Copilot reviewed 4 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/lib.rs Reintroduces canonicalization/realpath handling for the entry directory and resolved path.
src/tests/symlink.rs Updates Windows unsupported-path test to match the reverted canonicalization behavior.
src/tests/resolve.rs Adds coverage for symlinked package resolution with nested node_modules.
fixtures/symlink-with-nested-node_modules/.gitignore Ensures the fixture’s node_modules contents are not ignored.
fixtures/symlink-with-nested-node_modules/foo/node_modules/foo/index.js Fixture content for nested node_modules symlink scenario.
fixtures/symlink-with-nested-node_modules/foo/node_modules/dep/index.js Fixture content for nested node_modules symlink scenario.
fixtures/pnp/index.test.mjs Removes debug console.log from fixture test.
Files not reviewed (1)
  • fixtures/symlink-with-nested-node_modules/.gitignore: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib.rs Resolved
Comment thread src/tests/symlink.rs Resolved
@codspeed

codspeed Bot commented May 19, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 13 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing fix/symlink-with-nested-node_modules (4a0224a) with main (00dd8d6)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@JounQin
JounQin force-pushed the fix/symlink-with-nested-node_modules branch from dd1a926 to 4a0224a Compare May 19, 2026 03:20
@sonarqubecloud

Copy link
Copy Markdown

@JounQin
JounQin merged commit 299ae61 into main May 19, 2026
26 checks passed
@JounQin
JounQin deleted the fix/symlink-with-nested-node_modules branch May 19, 2026 03:30
This was referenced May 19, 2026
hanzo-dev pushed a commit to hanzoai/unrs-resolver that referenced this pull request Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants