question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

with-zones example causes WebSocket connection fail (HMR) when visiting proxied path

See original GitHub issue

What version of Next.js are you using?

12.0.7

What version of Node.js are you using?

14.17.6

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

N/A

Describe the Bug

Following the instructions in the “with-zones” example and navigating to /blog will case the repeating warning to be displayed:

WebSocket connection to 'ws://localhost:3000/blog/_next/webpack-hmr' failed: WebSocket is closed before the connection is established.

Also because of this HMR is not working when editing files in the blog Next.js app.

Expected Behavior

The HMR client should probably reconnect to the proxied apps HMR server automatically?

To Reproduce

Clone https://github.com/vercel/next.js/tree/canary/examples/with-zones and follow the instructions to start both Next.js apps in dev mode (next dev). Open http://localhost:3000 in a browser and navigate to blog. Wait on the WebSocket connection fail warning to display in the console.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:6

github_iconTop GitHub Comments

6reactions
vvlad3commented, Feb 4, 2022

The same for me. In Firefox the home app host even completely stuck after some time with following error:

Firefox can’t establish a connection to the server at ws://localhost:3000/blog/_next/webpack-hmr.
The connection to ws://localhost:3000/blog/_next/webpack-hmr was interrupted while the page was loading.
1reaction
teovillanuevacommented, Jul 8, 2022

Hey, just created a PR for this issue. The solution seems to work great 😇

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebSocket connection to 'ws:<URL>/_next/webpack-hmr' failed
I am having websocket error - "WebSocket connection to 'ws:/_next/webpack-hmr' failed: WebSocket is closed before the connection is ...
Read more >
WebSocket - Wikipedia
WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection. The WebSocket protocol was ...
Read more >
Implementing WebSocket communication in Next.js
In this article, I will use Socket.io to show a WebSocket connection between a server and a Next.js application.
Read more >
WebSockets for fun and profit - Stack Overflow Blog
Let's start with the basics: WebSocket is a technology that allows a client to establish two-way (“full-duplex”) communication with the ...
Read more >
How do I troubleshoot WebSocket issues in Agents (All ...
WebSocketConnectionException: Failed to create connection ... for example: $ cd /path/to/tomcat/bin $ lsof | grep websocket.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found