Repository navigation
fix(vite): skip websocket upgrade listener in middleware mode - #4647
Conversation
|
@benjamincanac is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe Vite development server now registers the WebSocket upgrade listener only when ChangesVite upgrade handling
Priority: ➖ Normal Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 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 |
commit: |
Nuxt 5 ships only as nightly packages, so `nuxt`, `@nuxt/kit`, `@nuxt/schema` and `@nuxt/nitro-server` are aliases of their `5x` dist-tag, and `nitro` of its own nightly — in the catalog and in `overrides:`, so `@nuxt/nitro-server`'s dependency follows — because the newest Nitro beta crashes `nuxt dev` with WebSockets on (nitrojs/nitro#4647, merged, not yet released). One disabled Renovate rule holds every alias. What the h3 1.x/2.x split forced goes: - the `h3` override, the `h3 <2` Renovate cap and the catalog's 1.x range; `h3` moves to 2.x and the app stops declaring it, since its server imports `nuxt/server` and the tRPC module `nitro/h3` - the `crossws` override: Nitro 3 depends on the 0.4 line itself, and the 0.3 copy left belongs to h3 1.x under the modules still on it - the UnoCSS trio's tilde and its `<66.10` rule: the inspector's `devframe` resolves its own h3 2.x - `nitropack`, replaced by `nitro` Nuxt 5 applies its Nitro 2 compatibility layer by itself to the modules whose server code still imports h3 1.x, so no override forces an h3 major in either direction. What it does not reach is a module's build-time code and a module's own dependencies, which Nitro 3 resolves from the app's root. So the branch carries, each with an `@TODO`: - a patch to nuxt-security, whose `prerender:done` hook reads Nitro 2's build-time `nitro.storage` and fails every prerender - `lru-cache`, `chokidar`, `remark-emoji` and `mocked-exports` as the app's dev dependencies, for the storage drivers, MDC plugin and bufferutil alias the server bundle imports The app's manifest also exports its own `package.json`, so the MCP server reads its version by package name: Nuxt 5's server project maps no `@@`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01TUTQr3Wd3pfCwmkTuyzoYi
Nuxt 5 ships only as nightly packages, so `nuxt`, `@nuxt/kit`, `@nuxt/schema` and `@nuxt/nitro-server` are aliases of their `5x` dist-tag, and `nitro` of its own nightly — in the catalog and in `overrides:`, so `@nuxt/nitro-server`'s dependency follows — because the newest Nitro beta crashes `nuxt dev` with WebSockets on (nitrojs/nitro#4647, merged, not yet released). One disabled Renovate rule holds every alias. What the h3 1.x/2.x split forced goes: - the `h3` override, the `h3 <2` Renovate cap and the catalog's 1.x range; `h3` moves to 2.x and the app stops declaring it, since its server imports `nuxt/server` and the tRPC module `nitro/h3` - the `crossws` override: Nitro 3 depends on the 0.4 line itself, and the 0.3 copy left belongs to h3 1.x under the modules still on it - the UnoCSS trio's tilde and its `<66.10` rule: the inspector's `devframe` resolves its own h3 2.x - `nitropack`, replaced by `nitro` Nuxt 5 applies its Nitro 2 compatibility layer by itself to the modules whose server code still imports h3 1.x, so no override forces an h3 major in either direction. What it does not reach is a module's build-time code and a module's own dependencies, which Nitro 3 resolves from the app's root. So the branch carries, each with an `@TODO`: - a patch to nuxt-security, whose `prerender:done` hook reads Nitro 2's build-time `nitro.storage` and fails every prerender - `lru-cache`, `chokidar`, `remark-emoji` and `mocked-exports` as the app's dev dependencies, for the storage drivers, MDC plugin and bufferutil alias the server bundle imports The app's manifest also exports its own `package.json`, so the MCP server reads its version by package name: Nuxt 5's server project maps no `@@`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01TUTQr3Wd3pfCwmkTuyzoYi
Nuxt 5 ships only as nightly packages, so `nuxt`, `@nuxt/kit`, `@nuxt/schema` and `@nuxt/nitro-server` are aliases of their `5x` dist-tag, and `nitro` of its own nightly — in the catalog and in `overrides:`, so `@nuxt/nitro-server`'s dependency follows — because the newest Nitro beta crashes `nuxt dev` with WebSockets on (nitrojs/nitro#4647, merged, not yet released). One disabled Renovate rule holds every alias. What the h3 1.x/2.x split forced goes: - the `h3` override, the `h3 <2` Renovate cap and the catalog's 1.x range; `h3` moves to 2.x and the app stops declaring it, since its server imports `nuxt/server` and the tRPC module `nitro/h3` - the `crossws` override: Nitro 3 depends on the 0.4 line itself, and the 0.3 copy left belongs to h3 1.x under the modules still on it - the UnoCSS trio's tilde and its `<66.10` rule: the inspector's `devframe` resolves its own h3 2.x - `nitropack`, replaced by `nitro` Nuxt 5 applies its Nitro 2 compatibility layer by itself to the modules whose server code still imports h3 1.x, so no override forces an h3 major in either direction. What it does not reach is a module's build-time code and a module's own dependencies, which Nitro 3 resolves from the app's root. So the branch carries, each with an `@TODO`: - a patch to nuxt-security, whose `prerender:done` hook reads Nitro 2's build-time `nitro.storage` and fails every prerender - `lru-cache`, `chokidar`, `remark-emoji` and `mocked-exports` as the app's dev dependencies, for the storage drivers, MDC plugin and bufferutil alias the server bundle imports The app's manifest also exports its own `package.json`, so the MCP server reads its version by package name: Nuxt 5's server project maps no `@@`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01TUTQr3Wd3pfCwmkTuyzoYi (cherry picked from commit 665d781)
🔗 Linked issue
None.
❓ Type of change
📚 Description
With
features.websocketenabled,configureViteDevServercallsserver.httpServer!.on("upgrade"). In middleware mode Vite has no http server, sohttpServerisnulland the dev server crashes on startup:This is what happens with the Nuxt 5 nightlies, which mount Nitro as a Vite environment and run Vite in middleware mode. Any app with
nitro.features.websocketcan't startnuxt dev.The listener is now skipped when there is no
httpServer, the same way theSIGINThandler below already leaves middleware mode alone. The embedding server owns the real listener there, and it can forward upgrades itself throughserver.environments.nitro.devServer.upgrade().I applied the same guard to the installed
3.0.260903-betain a Nuxt app with websockets on, andnuxt devboots and serves pages again. WebSockets in dev still need Nuxt to forward upgrades, which is a separate change on the Nuxt side.📝 Checklist