Upgrade Turbopack HMR websocket in nextjs proxy - #90
Merged
Conversation
Next 16 defaults `next dev` to Turbopack, which serves its HMR websocket at /_next/hmr rather than the legacy webpack /_next/webpack-hmr. The template only upgraded the webpack path, so the Turbopack connection fell through to `location /` without upgrade headers and failed. Since Next 16.3 that failure aborts client hydration, leaving dev pages non-interactive. Match both paths with one regex block so HMR works under either bundler. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Next 16 defaults
next devto Turbopack, which serves its HMR websocket at/_next/hmrinstead of the legacy webpack/_next/webpack-hmr. Thenextjsproxy template only has an upgrade block for the webpack path, so the Turbopack connection falls through tolocation /(noUpgrade/Connectionheaders) and fails the WebSocket handshake.Since Next 16.3 that failed connection is established during client bootstrap/hydration, and its failure aborts hydration — leaving dev pages non-interactive (e.g. login forms don't respond). It only affects local dev behind this proxy; production (
next start) has no HMR and is unaffected.Fix
Match both HMR paths with a single regex
location, so it works under either bundler without duplicating the proxy directives:A regex location outranks the
location /prefix, so both paths still match here.${NGINX_PROXY_PASS}has no URI part, so it's valid in a regex location.Verification
Built the
nextjsimage with this change and ran a Next 16.3 (Turbopack) app behind it. The/_next/hmrwebsocket now completes the upgrade (HTTP 101), stays open, and receives Turbopack HMR messages (isrManifest,turbopack-connected). Login / interactivity restored. The legacy/_next/webpack-hmrpath continues to upgrade fornext dev --webpack.