Repository navigation
fix(nitro): correct dev and build behaviour for nitro/vite - #35931
Conversation
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
Merging this PR will improve performance by 30.22%
|
| 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)
Footnotes
-
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. ↩
8f60c1a to
be0b05d
Compare
be0b05d to
9c88965
Compare
WalkthroughThe 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
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/nuxt/test/cache.test.ts (1)
21-45: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider capturing server stderr for easier CI diagnosis.
renderIndexspawns the built server withstdio: '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 examplestdio: ['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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (6)
packages/nitro-server/src/index.tspackages/nitro-server/src/vite.tspackages/nuxt/src/core/builder.tspackages/nuxt/src/core/cache.tspackages/nuxt/test/cache.test.tspatches/[email protected]
🔗 Linked issue
📚 Description
spotted these issues in #35891 - this pulls them out into a standalone commit. (also patching nitro with a commit already on
mainto avoid a test failure)