Skip to content

Stop the module walk at the drive root on Windows (infinite loop) - #12

Merged
DylanPiercey merged 1 commit into
mainfrom
fix-windows-root-walk
Jul 11, 2026
Merged

Stop the module walk at the drive root on Windows (infinite loop)#12
DylanPiercey merged 1 commit into
mainfrom
fix-windows-root-walk

Conversation

@DylanPiercey

Copy link
Copy Markdown
Contributor

Description

The node_modules and imports walks terminated only on dir !== ctx.root, with root defaulting to "/" — which a drive-rooted Windows path never equals, since dirname("D:/") returns "D:/" itself. Any resolution that failed to resolve (missing package, or unsatisfiable exports under silent) therefore looped forever on Windows. Both walks now also stop when a directory is its own parent, i.e. the file system root.

Reproduced before the fix with resolveSync("missing-pkg", { from: "C:\\project\\src\\index.js", silent: true, ... }) — hard hang, killed by timeout; after the fix it returns undefined. New tests cover the missing-module throw, the silent variant, and #import walks from Windows paths without the root option — the existing Windows tests all passed root: "C:\\", which is why the loop was never hit in CI.

Motivation and Context

This is what's hanging the Windows CI job in marko-js/vite (https://github.com/marko-js/vite/actions/runs/29170390485/job/86590525203) since @marko/vite switched its CJS detection to resolve-sync: isCJSModule probes bare ids with silent: true on every .js resolve, and the first unresolvable id on a Windows runner spins forever.

Checklist:

  • I have updated/added documentation affected by my changes.
  • I have added tests to cover my changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KZUGLZL3YoBToFLSEv2Nys


Generated by Claude Code

The node_modules and imports walks terminated only when reaching
ctx.root (default "/"), which a drive-rooted windows path never
equals — dirname("D:/") returns "D:/" itself. Any resolution that
failed to resolve (missing package, unsatisfiable exports under
silent) therefore looped forever on windows. The walk now also stops
when a directory is its own parent, i.e. the file system root.
@changeset-bot

changeset-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cf39f9a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
resolve-sync Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 35 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7033c5c5-37ca-4064-aa7c-cdb9f6761688

📥 Commits

Reviewing files that changed from the base of the PR and between 14c7018 and cf39f9a.

📒 Files selected for processing (3)
  • .changeset/windows-root-walk.md
  • src/__tests__/index.test.ts
  • src/index.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-windows-root-walk

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

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.01%. Comparing base (14c7018) to head (cf39f9a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #12      +/-   ##
==========================================
+ Coverage   96.95%   97.01%   +0.06%     
==========================================
  Files           1        1              
  Lines         394      402       +8     
  Branches       83       87       +4     
==========================================
+ Hits          382      390       +8     
  Misses         11       11              
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 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.

@DylanPiercey
DylanPiercey merged commit 93fe85c into main Jul 11, 2026
12 checks passed
@DylanPiercey
DylanPiercey deleted the fix-windows-root-walk branch July 11, 2026 22:36
@github-actions github-actions Bot mentioned this pull request Jul 11, 2026
@github-project-automation github-project-automation Bot moved this to Done in Roadmap Jul 14, 2026
@DylanPiercey DylanPiercey self-assigned this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant