create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Updating Files Does not Cause HMR Reload

Open danielstern opened this issue 10 years ago • 51 comments

I'm working in an application with lots of nested directories and .js files.

Sometimes, after I modify and save the file, it simply... does not update or rebuild. I have to stop the process and restart it.

What's the solution to this?

danielstern avatar Sep 16 '16 16:09 danielstern

I had this issue when working with a project that was in a dropbox folder. Hasn't affected any of my projects were outside the folder though.

tbillington avatar Sep 16 '16 17:09 tbillington

Not exactly the same, but feels related: Sometimes saving a js-file doesn't trigger the livereload. When I save it a second time it works. Sorry for the lack of details, but happens every now and then and I haven't been able to pinpoint the cause. On windows 10, latest CRA, editing with vim in gitbash.

ippa avatar Sep 16 '16 18:09 ippa

Same here. In fact I have a very simple project with no nested directories and the rebuilding/reloading is spotty at best. It will just stop rebuilding and hot-reloading so I am continuously having to stop the process and start it all over again. IMHO this is the biggest impedance to a smooth development experience with CreateReactApp. You guys have done such an amazing job thus far, if you could just get this and css preprocessors working you will have nailed it! Keep up the good work!

cpeele00 avatar Sep 16 '16 20:09 cpeele00

Can you reproduce this with a freshly created app, or only in existing apps? Has this been always happening, or just recently? Could you please share your system versions?

gaearon avatar Sep 16 '16 20:09 gaearon

This could be related to the "safe write" feature some editors use. See "Working with editors/IDEs supporting safe write" from the webpack-dev-server docs.

If this fixes it, and I think it will because I've seen dozens of issues in WDS because of this, I'd suggest to very clearly document this somewhere in CRA :).

SpaceK33z avatar Sep 17 '16 21:09 SpaceK33z

@SpaceK33z

Thanks for jumping in. I totally forgot about it.

@danielstern @tbillington @ippa @cpeele00

Does this help?

gaearon avatar Sep 17 '16 21:09 gaearon

@gaearon I'll give it a shot and will get back to you. Thanks!

cpeele00 avatar Sep 18 '16 03:09 cpeele00

@SpaceK33z: that url seems broken? it doesn't jump to any specific part of the page and I can't even find the word "safe".

ippa avatar Sep 18 '16 11:09 ippa

It didn't show up for me at first but I saw it after refresh.

screen shot 2016-09-18 at 14 41 39

gaearon avatar Sep 18 '16 11:09 gaearon

@ippa, apparently some dude renamed the whole wiki page for webpack-dev-server to "react-hot", causing some weird issues :(. I renamed it back now, so it should work again.

@gaearon haha see your comment just popping up, see above ;p.

SpaceK33z avatar Sep 18 '16 11:09 SpaceK33z

I have a fresh install of create-react-app on Debian 8.5 using text editor Atom and Chrome for browser. When I change App.js and save the reloading is not happening. Any ideas?

GramParallelo avatar Sep 19 '16 19:09 GramParallelo

Some more things to try here: https://webpack.github.io/docs/troubleshooting.html#watching

gaearon avatar Sep 19 '16 21:09 gaearon

@gaearon Absolutely, I was using IntelliJ. It turns out, the Safe Write feature was causing this.Is there some kind of universal editor_config setting that could disable this in editors?

danielstern avatar Sep 20 '16 17:09 danielstern

@danielstern, unfortunately this is not supported in editorconfig. But it's a great idea I think! Maybe propose that to the people at http://editorconfig.org/ ?

SpaceK33z avatar Sep 20 '16 17:09 SpaceK33z

Another thing that can cause HMR to stop working is parenthesis in a path name. https://github.com/webpack/webpack/issues/2753

jameshibbard avatar Oct 20 '16 11:10 jameshibbard

@danielstern what did your npm tests return?

I was facing something similar and I had to increase the the max_users_watches http://stackoverflow.com/questions/16748737/grunt-watch-error-waiting-fatal-error-watch-enospc

qjflores avatar Nov 16 '16 17:11 qjflores

Thank god, this issue was driving me crazy. The 'disable safe write' thing should be in bold in wepback docs...

CodeJjang avatar Dec 02 '16 17:12 CodeJjang

The 'disable safe write' thing should be in bold in wepback docs...

Oh I made sure of that ;). It's mentioned in the watch docs and is explained at the top of the "how to develop" guide.

SpaceK33z avatar Dec 02 '16 19:12 SpaceK33z

Anybody wants to make a PR to Troubleshooting in CRA User Guide?

gaearon avatar Dec 02 '16 19:12 gaearon

FWIW, i just tried create-react-app for the first time and hit this. I moved my project out of my Dropbox folder and the problem went away immediately.

elynde avatar Dec 28 '16 06:12 elynde