Skip to content

fix(prerender): detect output collisions on case-insensitive filesystems - #4895

Merged
pi0 merged 1 commit into
mainfrom
fix/prerender-case-insensitive-collision
Oct 22, 2026
Merged

pi0 merged 1 commit into
mainfrom
fix/prerender-case-insensitive-collision

Conversation

@pi0x

@pi0x pi0x commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Follow-up to #4491 for #4487. Supersedes #4488.

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

#4491 claims each prerender output path before writing, so two routes resolving to one file are deduped instead of racing. The claim is keyed by the exact path, so routes that differ only in case (/About, /about) still write to one file on a case-insensitive filesystem. The second write silently replaces the first, and with prerender.concurrency > 1 the two writes can overlap and tear the file.

This lower-cases the claim key when the public dir is on a case-insensitive filesystem. Those routes then go through the same path as other aliases: identical output is shared, different output keeps the first route and warns.

Case sensitivity is probed once per prerender run (write a temp file in publicDir, look it up by its upper-cased name) rather than inferred from process.platform, since case-sensitive APFS volumes exist and Linux can mount case-insensitive ones. Lower-casing on a case-sensitive volume would drop a route's file.

This covers the remaining torn-write case without changing how files are written, so #4488 is no longer needed.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

test/prerender/collision.test.ts adds a /Case + /case case: on a case-insensitive filesystem one route is kept with a warning, otherwise both are written. Linux CI runs the case-sensitive branch. I checked the other branch locally by forcing detection on. test/unit/fs.test.ts covers the probe.

🤖 Generated with AI assistant

Routes differing only in case (`/About`, `/about`) write to one file on
case-insensitive volumes. Lower-case the output claim key when the public
dir is case-insensitive, so the second route is deduped like other aliases.
@pi0x
pi0x requested a review from pi0 as a code owner October 22, 2026 05:51
@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nitro.build Ready Ready Preview Oct 22, 2026 5:51am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e0cfb4f5-217c-4396-8d4f-f65be1227990
📥 Commits

Reviewing files that changed from the base of the PR and between 54a3b36 and b370cdf.

📒 Files selected for processing: 4
  • src/prerender/prerender.ts
  • src/utils/fs.ts
  • test/prerender/collision.test.ts
  • test/unit/fs.test.ts
+--------------------------------------------------------------------------+
| Your code is like a magic trick: now you see it... now it's `undefined`. |
+--------------------------------------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@pkg-pr-new

pkg-pr-new Bot commented Oct 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4895

commit: b370cdf

@pi0
pi0 merged commit 933ee52 into main Oct 22, 2026
13 of 14 checks passed
@pi0
pi0 deleted the fix/prerender-case-insensitive-collision branch October 22, 2026 05:53

This branch was successfully deployed

1 active deployment
Preview — b370cdfc Deployed Oct 22, 2026 by vercel[bot]
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