fix(vite,nitro): link null-byte virtual css through `/@id/` in dev by danielroe · Pull Request #36549 · nuxt/nuxt · GitHub
Skip to content

fix(vite,nitro): link null-byte virtual css through /@id/ in dev - #36549

Merged
danielroe merged 1 commit into
mainfrom
fix/dev-css-nul-href
Oct 11, 2026
Merged

danielroe merged 1 commit into
mainfrom
fix/dev-css-nul-href

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

📚 Description

with @unocss/nuxt in dev, the SSR HTML contains a stylesheet link with a literal NUL byte in it:

<link rel="stylesheet" href="/_nuxt/\0/__uno.css" crossorigin>

the HTML tokenizer replaces the NUL with U+FFFD, so the browser requests /_nuxt/%EF%BF%BD/__uno.css - and uno happens to resolve that by suffix, but it means there are two copies of its stylesheet injected.

this PR maps non-path ids to /@id/ (with \0 as __x00__) before they become links, the same way Vite itself does. this also applies to bare virtual ids like virtual:foo.css, which only happened to work before....

@coldtea-pr-lens

coldtea-pr-lens Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

@github-actions github-actions Bot added 5.x 🐛 bug Something isn't working as expected labels Oct 10, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

pnpm add https://pkg.pr.new/@nuxt/kit@36549
npm i https://pkg.pr.new/@nuxt/kit@36549
yarn add https://pkg.pr.new/@nuxt/kit@36549.tgz

@nuxt/nitro-server

pnpm add https://pkg.pr.new/@nuxt/nitro-server@36549
npm i https://pkg.pr.new/@nuxt/nitro-server@36549
yarn add https://pkg.pr.new/@nuxt/nitro-server@36549.tgz

nuxt

pnpm add https://pkg.pr.new/nuxt@36549
npm i https://pkg.pr.new/nuxt@36549
yarn add https://pkg.pr.new/nuxt@36549.tgz

@nuxt/rspack-builder

pnpm add https://pkg.pr.new/@nuxt/rspack-builder@36549
npm i https://pkg.pr.new/@nuxt/rspack-builder@36549
yarn add https://pkg.pr.new/@nuxt/rspack-builder@36549.tgz

@nuxt/schema

pnpm add https://pkg.pr.new/@nuxt/schema@36549
npm i https://pkg.pr.new/@nuxt/schema@36549
yarn add https://pkg.pr.new/@nuxt/schema@36549.tgz

@nuxt/vite-builder

pnpm add https://pkg.pr.new/@nuxt/vite-builder@36549
npm i https://pkg.pr.new/@nuxt/vite-builder@36549
yarn add https://pkg.pr.new/@nuxt/vite-builder@36549.tgz

@nuxt/vite-server

pnpm add https://pkg.pr.new/@nuxt/vite-server@36549
npm i https://pkg.pr.new/@nuxt/vite-server@36549
yarn add https://pkg.pr.new/@nuxt/vite-server@36549.tgz

@nuxt/webpack-builder

pnpm add https://pkg.pr.new/@nuxt/webpack-builder@36549
npm i https://pkg.pr.new/@nuxt/webpack-builder@36549
yarn add https://pkg.pr.new/@nuxt/webpack-builder@36549.tgz

commit: 0a51067

@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 01d8396d-c13f-494f-a563-b1b296a4649b

📥 Commits

Reviewing files that changed from the base of the PR and between 1438bbb and 0a51067.


📒 Files selected for processing (5)
  • packages/nitro-server/src/vite.ts
  • packages/vite/src/utils/css.ts
  • packages/vite/test/css.test.ts
  • test/basic.test.ts
  • test/fixtures/basic/nuxt.config.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.



Walkthrough

CSS collection in Nitro SSR and Vite now converts module IDs to Vite development URLs. Tests cover path-based, wrapped, virtual, and NUL-prefixed IDs. A development fixture registers a NUL-prefixed virtual stylesheet, and an integration test checks its rendered URL and CSS response.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 0a510

The change appears ready to merge after normal checks; no actionable merge-blocking risk was identified.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly summarises the main change: routing null-byte virtual CSS through Vite's /@id/ development URL format.
Description check Passed The description directly explains the null-byte CSS link issue, its impact on UnoCSS, and the proposed /@id/ mapping.
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.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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.

@danielroe
danielroe added this pull request to the merge queue Oct 11, 2026
Merged via the queue into main with commit 60fac62 Oct 11, 2026
40 checks passed
@danielroe
danielroe deleted the fix/dev-css-nul-href branch October 11, 2026 08:06
@github-actions github-actions Bot mentioned this pull request Oct 10, 2026
This was referenced Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.x 🐛 bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant