Skip to content

fix(nuxt): Keep Nitro 2 WebSocket handlers resolvable with the managed tunnel - #26082

Open
chan-mai wants to merge 1 commit into
getsentry:developfrom
chan-mai:fix/nuxt-tunnel-websocket-route
Open

chan-mai wants to merge 1 commit into
getsentry:developfrom
chan-mai:fix/nuxt-tunnel-websocket-route

Conversation

@chan-mai

@chan-mai chan-mai commented Nov 4, 2026

Copy link
Copy Markdown

Why:
The tunnel plugin for Nitro 2 added in #25418 inserts a layer with an empty route '' at the top of the h3 application stack. The h3 WebSocket handler resolution logic skips layers with a route of '/', but it does not skip layers with ''. As a result, this layer matched all paths, preventing the app-defined WebSocket handler's upgrade hook from being called.

Changing the route to '/' causes this layer to be skipped during WebSocket handler resolution. For HTTP request processing, layers with a route of '/' continue to match all paths as well, so the tunnel behavior remains unchanged. In #25991, the maintainer approved this change as a temporary fix until #26001 is merged.

How to review:
The change in tunnel-legacy.server.ts is just a single line for the route value. The added test uses h3's createApp and createRouter to apply the plugin to an app where the router is mounted at /, just like Nitro. It then verifies the following three points:

  • The return value of the WebSocket handler resolution process includes the app's upgrade hook.
  • Requests to the tunnel are handled by the tunnel logic.
  • Requests other than to the tunnel are handled by subsequent layers.

I have confirmed that the first test fails with the code before the fix.

Unsure about:
I have not added an E2E test using WebSockets in an actual Nuxt app. All I ran for verification were the unit tests for the nuxt package and the linting for the modified files.

Closes #25991

@chan-mai
chan-mai requested a review from a team as a code owner November 4, 2026 07:16
@chan-mai
chan-mai requested review from chargome and s1gr1d and removed request for a team November 4, 2026 07:16
@github-actions github-actions Bot added the external PR from an external contributor label Nov 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external PR from an external contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@sentry/nuxt 11.10.0 tunnel plugin causes Nitro 2 WebSocket handlers to fail to resolve

1 participant