Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot reload connection can fail on Windows #27298

Closed
MateusFP95 opened this issue Jul 19, 2021 · 13 comments · Fixed by #27306
Closed

Hot reload connection can fail on Windows #27298

MateusFP95 opened this issue Jul 19, 2021 · 13 comments · Fixed by #27306
Assignees

Comments

@MateusFP95
Copy link

What version of Next.js are you using?

11.0.1

What version of Node.js are you using?

v14.17.0

What browser are you using?

Edge 91.0.864.67 - Chrome 91.0.4472.124

What operating system are you using?

Windows 10 Pro 20H2

How are you deploying your application?

npm run dev

Describe the Bug

Hot reload / Fast Refresh isn't working.

I'm following the next tutorial, so here's my code:
npx create-next-app nextjs-blog --use-npm --example "https://github.com/vercel/next-learn-starter/tree/master/learn-starter"

Here https://nextjs.org/learn/basics/create-nextjs-app/editing-the-page it says that the page will live reload, just like react / vue, but it doenst reload.

On network tab I see this errors:
image

Approaches tried following google/yt tutorials:
Create next.config.js with FAST_REFRESH='TRUE'
Create webpack.config.js with TARGET = 'WEB'
Delete project and restarted from 0
npm ci
Delete node_modules and .next and recreated

Expected Behavior

Live reload should work.

To Reproduce

npx create-next-app nextjs-blog --use-npm --example "https://github.com/vercel/next-learn-starter/tree/master/learn-starter"

@MateusFP95 MateusFP95 added the bug Issue was opened via the bug report template. label Jul 19, 2021
@ijjk
Copy link
Member

ijjk commented Jul 19, 2021

Hi, can you provide more information on your environment? Are there any error messages in the console tab of your browser? Do you have any network configuration or proxying being done that could interfere with a persistent connection being opened to the local Next.js server?

@MateusFP95
Copy link
Author

Hi, can you provide more information on your environment? Are there any error messages in the console tab of your browser? Do you have any network configuration or proxying being done that could interfere with a persistent connection being opened to the local Next.js server?

Visual Studio Code about info:
Version: 1.57.1 (system setup)
Commit: 507ce72a4466fbb27b715c3722558bb15afa9f48
Date: 2021-06-17T13:28:07.755Z (4 wks ago)
Electron: 12.0.7
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Windows_NT x64 10.0.19042

No console messages, neither sucess or failure. Browser config is default, works fine with react/vue reload. No proxy.

Also tried to run Chrome on anonymous mode with extensions (ADBlock) off, no changes. Edge was default, since I never really use it.

@ijjk
Copy link
Member

ijjk commented Jul 19, 2021

@MateusFP95 thanks for the additional info, can you confirm the Next.js version installed by running yarn why next or npm ls next? It looks like the example from the learn repo needs updating to the latest Next.js version.

@MateusFP95
Copy link
Author

@MateusFP95 thanks for the additional info, can you confirm the Next.js version installed by running yarn why next or npm ls next? It looks like the example from the learn repo needs updating to the latest Next.js version.

Running npm ls next I got next@10.0.6, which I get from the tutorial.

But, after I run npm install react@latest react-dom@latest I got the same results, hot reload not work and CANCELED status on network tab
image

@ijjk
Copy link
Member

ijjk commented Jul 19, 2021

Did you also run npm install next@latest it looks like that one isn't included in the snippet above. If it still doesn't work after ensuring the latest Next.js version is installed could you try running npm install next@10.0.5 to see if it is related to this comment and potentially this issue

@MateusFP95
Copy link
Author

Did you also run npm install next@latest it looks like that one isn't included in the snippet above. If it still doesn't work after ensuring the latest Next.js version is installed could you try running npm install next@10.0.5 to see if it is related to this comment and potentially this issue

next@latest installed next@11.0.1, which didn't work and apresent same behaviour (nothing on console, no hot reload, canceled network messages, etc).

But npm install next@10.0.5 Worked!
With console messages
image
And 0 network errors
image

@ijjk
Copy link
Member

ijjk commented Jul 19, 2021

Interesting thanks for testing that! Glad we've narrowed in on a version, could you try to narrow in on a specific canary it occurred on so we can try to figure out which change caused this to not work? There are 12 canaries between v10.0.5 and v10.0.6 they can be installed with npm install next@10.0.5-canary.6 replace .5 with the canary number from 1 - 12

I'm not able to reproduce this on a Windows 10 Pro laptop I have access to so it may be specific to certain Windows versions 🤔

@ijjk ijjk changed the title Hot reload not working => webpack-hmr?page=/ CANCELED Hot reload connection can fail on Windows Jul 19, 2021
@shadowwalker
Copy link

shadowwalker commented Jul 19, 2021

Test result below on yarn create next-app:

  • next@10.0.6-canary.7 works fine
  • next@10.0.6-canary.8 doesn't work

Versions

  • Windows 10 Pro 21H1 OS Build 19043.1110
  • Node versions manager nvm-windows 1.1.7
  • Node.js version 14.17.3
  • Yarn version 1.22.10
  • React and React-DOM 17.0.2
  • Powershell 7.1.3

@ijjk I don't think it's related to certain windows build, as create-react-app works totally fine for me, umi.js (which uses @pmmmwh/react-refresh-webpack-plugin, see here) also works fine.

@ijjk
Copy link
Member

ijjk commented Jul 19, 2021

@shadowwalker yeah it sounds like this may be related to #20409

@ijjk
Copy link
Member

ijjk commented Jul 19, 2021

@shadowwalker @MateusFP95 could you please confirm this is the issue by testing a patch that reverts that PR's host change by running npm install next@https://github.com/ijjk/next-update-loader.git#3e01c6bbc9f808f41c49c1e2118ca751d89ca725?

@shadowwalker
Copy link

shadowwalker commented Jul 19, 2021

@shadowwalker @MateusFP95 could you please confirm this is the issue by testing a patch that reverts that PR's host change by running npm install next@https://github.com/ijjk/next-update-loader.git#3e01c6bbc9f808f41c49c1e2118ca751d89ca725?

@ijjk Confirm the patch fix the issue, fast refresh works as expected after apply the patch

@ijjk ijjk added kind: bug and removed bug Issue was opened via the bug report template. labels Jul 19, 2021
@ijjk ijjk self-assigned this Jul 19, 2021
@kodiakhq kodiakhq bot closed this as completed in #27306 Jul 19, 2021
kodiakhq bot pushed a commit that referenced this issue Jul 19, 2021
This fixes a case where the HMR connection for fast refresh would fail to connect on Windows due to a change being made to the default host being listened to. Previously we didn't set a default for the `host` value when calling `server.listen` which allowed the default listening behavior to be used although in #20409 a default of `0.0.0.0` was added which causes conflicts for some set-ups mainlly on Windows it seems. 

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added (N/A)
- [x] Errors have helpful link attached, see `contributing.md`

Fixes: #27298
Fixes: #27254
Fixes: #4456 (comment)
Fixes: #20409 (comment)
x-ref: #20409
@ijjk
Copy link
Member

ijjk commented Jul 19, 2021

This has been updated in v11.0.2-canary.17 of Next.js, please update and give it a try!

flybayer pushed a commit to blitz-js/next.js that referenced this issue Aug 19, 2021
This fixes a case where the HMR connection for fast refresh would fail to connect on Windows due to a change being made to the default host being listened to. Previously we didn't set a default for the `host` value when calling `server.listen` which allowed the default listening behavior to be used although in vercel#20409 a default of `0.0.0.0` was added which causes conflicts for some set-ups mainlly on Windows it seems. 

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added (N/A)
- [x] Errors have helpful link attached, see `contributing.md`

Fixes: vercel#27298
Fixes: vercel#27254
Fixes: vercel#4456 (comment)
Fixes: vercel#20409 (comment)
x-ref: vercel#20409
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants