Skip to content

fix(nitro): correct dev and build behaviour for nitro/vite - #35931

Merged
danielroe merged 5 commits into
mainfrom
fix/nitro-vite-environment
Aug 1, 2026
Merged

danielroe merged 5 commits into
mainfrom
fix/nitro-vite-environment

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

📚 Description

spotted these issues in #35891 - this pulls them out into a standalone commit. (also patching nitro with a commit already on main to avoid a test failure)

@github-actions github-actions Bot added the 🐛 bug Something isn't working as expected label Aug 1, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@35931

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@35931

nuxt

npm i https://pkg.pr.new/nuxt@35931

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@35931

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@35931

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@35931

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@35931

commit: 9c88965

@codspeed

codspeed Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 30.22%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 20 untouched benchmarks
⏩ 3 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ loadNuxtConfig in the basic test fixture (types) 22.4 ms 17.2 ms +30.22%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/nitro-vite-environment (9c88965) with main (9065425)

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. ↩

@danielroe
danielroe added this pull request to the merge queue Aug 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because the pull requests in the stack were not ordered correctly in the queue Aug 1, 2026
@danielroe
danielroe added this pull request to the merge queue Aug 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because the pull requests in the stack were not ordered correctly in the queue Aug 1, 2026
@danielroe
danielroe force-pushed the fix/nitro-vite-environment branch from 8f60c1a to be0b05d Compare August 1, 2026 13:16
@danielroe
danielroe added this pull request to the merge queue Aug 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Aug 1, 2026
Base automatically changed from fix/build-cache-collect-timing to main August 1, 2026 14:09
@danielroe
danielroe force-pushed the fix/nitro-vite-environment branch from be0b05d to 9c88965 Compare August 1, 2026 14:09
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The PR extends Nitro Vite development support with typed route generation, Nitro module invalidation, full reloads, and CSS propagation across SSR and Nitro workers. Nuxt build caching now stores and restores Nitro Vite client assets separately from regenerated SSR output. Cache tests cover both Vite environment modes and rendered output. The Nitro patch updates raw asset resolution and source-map consumer handling.

Possibly related PRs

  • nuxt/nuxt#35410: Both PRs modify Vite development-server invalidation and reload handling.
  • nuxt/nuxt#35891: Both PRs modify Nitro Vite support, Nuxt build-cache handling, and cache tests.
  • nuxt/nuxt#35834: Both PRs modify development CSS propagation through Nitro and SSR HMR channels.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarises the main changes to Nitro Vite development and build behaviour.
Description check ✅ Passed The description relates the changes to issues from PR #35891 and explains the Nitro patch included to prevent a test failure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/nitro-vite-environment

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.

@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.

🧹 Nitpick comments (1)
packages/nuxt/test/cache.test.ts (1)

21-45: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider capturing server stderr for easier CI diagnosis.

renderIndex spawns the built server with stdio: 'ignore'. If the server crashes on startup, the polling loop runs the full 30-second timeout and throws a generic "did not start" error with no diagnostic output. Capture stderr (for example stdio: ['ignore', 'ignore', 'pipe']) and include it in the thrown error to speed up debugging of flaky failures.

🔧 Proposed diff to capture stderr on startup failure
 async function renderIndex (outputDir: string) {
   const port = await getRandomPort('127.0.0.1')
+  let stderr = ''
   const server = spawn(process.execPath, [join(outputDir, 'server/index.mjs')], {
     env: { ...process.env, PORT: String(port), HOST: '127.0.0.1' },
-    stdio: 'ignore',
+    stdio: ['ignore', 'ignore', 'pipe'],
   })
+  server.stderr?.on('data', chunk => { stderr += chunk })
   try {
     const deadline = Date.now() + 30_000
     while (Date.now() < deadline) {
       const html = await fetch(`http://127.0.0.1:${port}/`).then(r => r.text()).catch(() => undefined)
       if (html) {
         return html
       }
       await new Promise(resolve => setTimeout(resolve, 100))
     }
-    throw new Error(`built server at ${outputDir} did not start`)
+    throw new Error(`built server at ${outputDir} did not start${stderr ? `: ${stderr}` : ''}`)
   } finally {
     server.kill()
   }
 }
🤖 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 `@packages/nuxt/test/cache.test.ts` around lines 21 - 45, Update renderIndex to
capture the spawned server’s stderr instead of ignoring it, while continuing to
ignore stdin and stdout. Accumulate the stderr output during startup and include
it in the timeout error thrown when the built server fails to start.
🤖 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.

Nitpick comments:
In `@packages/nuxt/test/cache.test.ts`:
- Around line 21-45: Update renderIndex to capture the spawned server’s stderr
instead of ignoring it, while continuing to ignore stdin and stdout. Accumulate
the stderr output during startup and include it in the timeout error thrown when
the built server fails to start.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3043a6f8-e17c-470a-bca9-b30dc158fc86

📥 Commits

Reviewing files that changed from the base of the PR and between 9065425 and 9c88965.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (6)
  • packages/nitro-server/src/index.ts
  • packages/nitro-server/src/vite.ts
  • packages/nuxt/src/core/builder.ts
  • packages/nuxt/src/core/cache.ts
  • packages/nuxt/test/cache.test.ts
  • patches/[email protected]

@danielroe
danielroe added this pull request to the merge queue Aug 1, 2026
Merged via the queue into main with commit f6533f8 Aug 1, 2026
34 checks passed
@danielroe
danielroe deleted the fix/nitro-vite-environment branch August 1, 2026 16:28
@github-actions github-actions Bot mentioned this pull request Aug 1, 2026
2 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant