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.

create-react-app 3.3 breaks HMR and linting

See original GitHub issue

Describe the bug

create-react-app 3.3 was released today with support for typescript 3.7.0 features. After updating react-scripts to 3.3.0 and typescript to 3.7.3, HMR and linting stopped working. If I run npm run start from the command line, everything works as normal. This functionality stopped working when running through visual studio launching the web page via spa.UseReactDevelopmentServer(npmScript: "start").

To Reproduce

  1. Create a new ASP.NET Core Web Application project and use the React.js and Redux template. Use .NET Core and ASP.NET Core 3.0 settings also.
  2. Open ClientApp/package.json and change typescript to 3.7.3, react-scripts to 3.3.0, and eslint to 6.7.2.
  3. Run the project and open up the developer tools in chrome. You can see in the console output that it never connects. If you have any linting errors, they don’t show up. If you make change to the source files, the page doesn’t reload.
  4. Go to the command line and into the ClientApp directory. Run npm run start and this will launch a window on port 3000 instead of the random port generated by Visual Studio. Open up chrome developer tools and look at the console. You can see that when running on the command line, that the functionality still works.

Further technical details

.NET Core SDK (reflecting any global.json):
 Version:   3.1.100
 Commit:    cd82f021f4

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.100\

Host (useful for support):
  Version: 3.1.0
  Commit:  65f04fb6db

Visual Studio 16.4.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
ManfredLangecommented, Jan 4, 2020

I may misread the code but it appears as if the Middleware for React development server makes an assumption that requests will never use HTTPs, see https://github.com/aspnet/AspNetCore/blob/c7937640a4079465d36441724933eae5a9ca0085/src/Middleware/SpaServices.Extensions/src/ReactDevelopmentServer/ReactDevelopmentServerMiddleware.cs#L45-L51

If I read the code correctly - and that may be a stretch - then this would also explain why switching the project to using HTTP instead of HTTPs when running from within VS works.

Update 05 Jan 2020: Workaround for users of Visual Studio 2019 (we’re on 16.4.2) is to switch to HTTP for debugging locally. It’d be nicer, though, if this was fixed in the extensions package itself, i.e. in Microsoft.AspNetCore.SpaServices.Extensions.

4reactions
JoshClosecommented, Dec 5, 2019

This is a default create-react-app setup with typescript though, and is fundamental to using react with the SPA templates.

I think I found the culprit.

https://github.com/facebook/create-react-app/commit/9f4cb4f0c0ed280fcd6c9faf13ebe2619a398942

If I run my site in http instead of https, everything works as normal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

create-react-app/CHANGELOG-3.x.md at main
We now enforce Rules of Hooks with eslint-plugin-react-hooks . If you are breaking any of the rules of Hooks this will cause your...
Read more >
Hot Reload is not working in my React App
I have created this app with npx create-react-app. After this i have deleted all the files except index.js in src folder. Then Hot...
Read more >
My create-react-app is failing to compile due to ESLint error
It seems that the react-scripts was causing the lint errors for me. The newest version of the react-scripts:"4.0.0" may have some breaking ......
Read more >
Hot reloading with create-react-app without ejecting 🔥 ⏏️
With a few lines of code, you can setup a new create-react-app project with hot-module-replacement (HMR). Spin up a new react app with...
Read more >
Create-react-app my-app takes 1.5 - 2 hours. Why?
Here's the output I'm getting. My machine is not weak by any means. 2.8 GHz Quad-Core Intel Core i7, 16gb ram, 256 SDD,...
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