create-react-app: Chrome debugger breakpoints fail with react-scripts 2.x after hot-update
Is this a bug report?
yes
Did you try recovering your dependencies?
test-cra $npm --version 5.6.0
test-cra $yarn --version 1.12.3
Which terms did you search for in User Guide?
I looked for “hot-update” and “breakpoint”
Environment
System: OS: macOS High Sierra 10.13.6 CPU: x64 Intel® Core™ i7-7820HQ CPU @ 2.90GHz Binaries: Node: 8.11.1 - ~/.nvm/versions/node/v8.11.1/bin/node Yarn: 1.12.3 - /usr/local/bin/yarn npm: 5.6.0 - ~/.nvm/versions/node/v8.11.1/bin/npm Browsers: Chrome: 71.0.3578.98 Firefox: 63.0.1 Safari: 11.1.2 npmPackages: react: ^16.7.0 => 16.7.0 react-dom: ^16.7.0 => 16.7.0 react-scripts: 2.1.1 => 2.1.1 npmGlobalPackages: create-react-app: Not Found
Steps to Reproduce
- ran “yarn create react-app test-cra”
- ran “yarn install”
- ran “yarn start”
- Chrome opened a window for http://localhost:3000, with the app in it
- I opened Chrome dev tools and went to the source tab
- I hit cmd-P and opened App.js
- I set a breakpoint at line 7, the first line of the render() method
- I clicked on the “reload this page” arrow in the “React App” browser window
- the debugger in dev tools window stopped at the breakpoint
- I hit F8 to unpause
** this is all good, and I am able to repeat steps 8-10 successfully any number of times
- in IntelliJ I edited the App.js file so it was like this:
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt={this.foo} />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
foo = 'bar';
}
export default App;
NOTE: I did not move the position of the breakpointed line within the file.
- I saw that the app recompiled and reloaded successfully. The code as pasted above is what appeared in the devtools source tab, and the breakpoint was positioned at the same place. However, the debugger did not stop at the breakpoint.
- I clicked on the “reload this page” arrow in the “React App” browser window, but the debugger does not stop there anymore. I see that at the bottom of the Source tab, it now says “(source mapped from main.{guid}.hot-update.js)”.
- I stopped execution of the yarn start task with control-C.
- I re-ran “yarn start”.
- the debugger does not stop on the initial page load, but it does stop on every subsequent page load (when I click the “reload this page” arrow).
- I see that on the bottom of the devtools Source tab, it now says “(source mapped from main.chunk.js)”.
My apologies if the format of how I described this is not matching the following bullet points - I think I have done what they ask, but in a more interleaved fashion. I think the essence is that I have described a reproducible demo with what I expected, what I did, and what happened as a result.
NOTES: this does NOT happen to me when I am using react-scripts 1.1.4 (in the full-blown app where I encountered the issue) but only appeared when I upgraded to 2.x (first 2.0.5 and now 2.1.1).
Thanks very much for your help with this!
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 76
- Comments: 71 (5 by maintainers)
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.
Using this to the
package.json
worked for me:"start:debug": "react-scripts --inspect start --no-cache --runInBand",
This issue is killing me
Goto node_modules/react-scripts/config/webpack.config.js, look up cheap-module-source-map and change to eval-source-map. This is temporary and you’ll have to do this every time you change your package configuration.
@Timer @ianschmitz can you help the community understand the prioritization of this issue? Breakpoints being unusable in CRA apps seems like it should be a top priority, but empirically it doesn’t seem to be.
Does Facebook not use CRA internally? Does Facebook not use breakpoints internally? Are breakpoints just not considered a critical feature? Something else entirely?
Thanks!
facing same issue here.
@real4 that’s not the problem we’re reporting.
I have Javascript source maps enabled
I have the no-cache option set in start npm task
Neither of those seem to solve the problem reported, it seems to come with hot reloading as @mustafahafidi said. When you just start the server the breakpoint works properly, but once you update your code and it’s hot reloaded it doesn’t work anymore.
Are there plans to solve this after a year? Thinking about starting the project ejecting or using another tool.
To fix the problem with sourcemaps in Chrome, you need to enable the ‘Enable JavaScript source maps’ settings
Still facing this issue as well.
Debugging in Chrome is unusable right now. This is major showstopper.
@RobertWHurst - turns out that the fix in #7022 isn’t the same issue as this one. This problem is still happening. FWIW, what I’ve seen in the past is that there are three separate (maybe related) problems in this area:
In all cases, restarting the debug session (stop debugging, stop the
npm start
process, restart thenpm start
process, and start debugging again) will fix the problem.I haven’t done the validation to figure out reliable repro cases for all these, so it’s possible that all three of these are the same root cause.
Hope this info is helpful. It looks like this issue and #8165 both reflect some (maybe all) of the problems that I described above.
Given that there’s a completely new hot-reload solution called Fast Refresh coming to React (it’s already been released for React Native), it’s possible that no fixes will be made for the current hot-reload solution.
Does anyone know if there’s an existing CRA issue that’s tracking adoption of the new Fast Refresh solution in CRA? I wasn’t able to find one.
This is now released. 😄
Switching source-maps from cheap-module-source-map to eval-source-map breaks the error overlay functionality. We can’t really have one fix breaking other things, so that change was reverted for now. You can pin react-scripts to 2.1.4 if you need to have Chrome debugging functionality. I have an issue open at Webpack to look at this https://github.com/webpack/webpack/issues/8910, feel free to subscribe to it for any updates.
This project is maintained by a team of volunteers that don’t work at Facebook (AFAIK). I can tell you that Facebook also doesn’t use CRA internally.
I have version 4.0.3 and the problem still persists on edge (chromium version) 88.0.705.74 package.json:
yarn version: 1.22.4
Hi, has anyone had any luck with this?
Breakpoints still are not working in react-scripts 3.3.1. I tried @jsdevtom 's solution but it did’t make any difference, also tried a variety of source map configs in webpack’s devtool property.
It’s getting really frustrating
UPDATE: I also tried downgrading react-scripts to 2.1.4 and breakpoints are still not working as expected…
I’ve still encountered this issue even when using solution presented by @jsdevtom . The only sure fire way I can set breakpoints is by using
debugger;
in code. It’s not as pleasant as just setting the point in devtools, but it makes things predictable at least.still have the problem, drive me crazy now i am putting
debugger
all over the codeIssue still exists as originally reported by @nerdcity
vscode 1.46.1 yarn 1.22.4 react-scripts 3.4.1 react 16.13.1
Both with Firefox 77.0.1 and Chromium 83.0.4103.97
I ended up working around this by using react-app-rewired. I am running react-scripts 3.0.1.
Steps:
npm install react-app-rewired --save-dev
oryarn add react-app-rewired --dev
config-overrides.js
config-overrides.js
:I’m just wondering why everyone is trying to replace the devtool with
eval-source-map
, there are many devtools available andcheap-module-eval-source-map
seems to work fine for me, unless I’m missing something.👍 same problem
I’m having the same issue. Working with react-scripts 2.0.5
@eliasbobadilla (and anyone else) - CRA just released v4, which includes Fast Refresh replacing Hot Reload. I’m not seeing the issue anymore now that I’ve upgraded.
https://github.com/facebook/create-react-app/releases/tag/v4.0.0
I’m curious if this has fixed the issue for others as well.
Switched to Firefox for this, supposedly it should keep logpoints there, lets see
@RobertWHurst - fix is merged so it should be in the next
react-scripts
release. Keep your eye onnpm outdated
.@russelldavis a release should be out shortly 😃
After upgrading to CRA v4. I can confirm this bug is no longer exist
I’m still having this issue with chrome. But works with “node scripts/start.js
--no-cache
” --no-cache flag. This issue is also related with locked https://github.com/facebook/create-react-app/issues/5846I can confirm that this is still an issue occasionally. I just ran into it again, even using the start:debug solution of @jsdevtom . I have no clue what to do to work around it, except using debugger statements.
So to clarify, is this still an issue? As someone looking to use the
react-error-overlay
plugin in a non-CRA app[1] (which already has full control of the sourcemap devtool) , this comment from @russelldavis seems concerning: https://github.com/facebook/create-react-app/issues/6433#issuecomment-464414558It seems like there’s no current way to have fully working sourcemaps as well as
react-error-overlay
working in an app?All of the comments in this thread mainly discuss switching the sourcemap type in webpack, but don’t seem to take into account that this will seemingly reintroduce #6433. Curious what the current state is and whether there’s an open webpack issue somewhere if it’s indeed a webpack bug.
[1] (or perhaps investigate using it as part of a React fast-refresh implementation: https://github.com/facebook/react/issues/16604#issuecomment-528663101)
If you can use cheap-eval sure. I’m not sure adding a dependency to regex the eval tool to the cheap one is so wise. I definitely know this would not fly within my team.
Also facing the same problem. I have to stop the development server and start it again. Thats a huge pain and time consumption. Is there any hack fix for this?
Same issue for me with:
seems to work randomly.
Adding the no-cache flag to the start script npm command doesn’t help, as suggested here: CRA chrome issue solution
Also confirming that this is still an issue even with @jsdevtom’s fix. I’m having to restart my app to get debugging work again after a hot reload.
I still have this problem, is there any solution for this issue?
The year is 2023! And this is a problem on a clean
create-react-app
If you launch the Chrome bugger with a breakpoint enabled it will hang loading the site. Now the runningreact-script start
is corrupted.If you then a) remove all breakpoints b)
react script start
c) Launch Chrome debugger again it will display, and then you can start adding breakpoints.Tested on two mutually exclusive computers.
react-scripts
: 5.0.1 Literally no changes tocreate-react-app
except to add a<button/>
to test clicking.One solution I found to solve this warning was to downgrade the react-script package to version 3.4.4 and this solved the warnings
@meatnordrink today at morning I got the last stable version of chrome 86.0.4240.183 , launched yesterday. https://chromereleases.googleblog.com/2020/11/stable-channel-update-for-desktop.html and the problem with breakpoints is gone.
Anyway I’m developing a new app some weeks ago. I think is a good oportunity to change to create-react-app 4.0.0 version now
@bugzpodder solution is a life saver 😃
I’m having the same issue using yarn. When I restart the server, then the debug works once until I hot reload the code.
Not sure if it’s related, but I am facing the issue without using react-scripts. I am only using react-hot-loader (4.12.18)
Same issue here. Running:
With Firefox 75 it works fine, though.
Still having this same issue with react script 3.3.0, the breakpoints works just sometimes with no apparent pattern
Try this package https://www.npmjs.com/package/react-breakpoint-fix
just install the package and run react-breakpoint-fix from the terminal.
This fixed it for me. I’m using react-scripts@3.x
@j3ko The error overlay displays wrong lines if cheap-module-eval-source-map is used.
@hmeerlo read @jsdevtom 's solution. it works