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

Webpacker HMR looking for json with content-type text/html with a 404 cause page reload #1375

Closed
AirWick219 opened this issue Mar 23, 2018 · 5 comments

Comments

@AirWick219
Copy link

I have got hmr set up where the webpack-dev-server if returning the correct hot-update.json back and it swapped the module without page reload. but there is an extra hot-update.json with a content-type of text/html that's is not there and throw a 404 which causes the page to reload. I was wondering if you guys have an idea of what that might be ??

webpacker 3.3.1,
webpack-dev-server: 2.11.2

screen shot 2018-03-23 at 5 16 47 pm

screen shot 2018-03-23 at 5 16 56 pm

@gauravtiwari
Copy link
Member

gauravtiwari commented Mar 26, 2018

@AirWick219 What version of Rails are you using? Do you have an example repo somewhere?

@AirWick219
Copy link
Author

I am on rails 5.1. Let me try to recreate this in my other repo.

I faught with this a little bit last night and it seems that the 6137e4 ... hash it is the same hash as the over all webpack compile hash from the console. Seems like something is going on with the webpack-dev-server.

I am not sure why its trying to look for that json in the generated boobstrap file for the other hash.

In this case, It's the 86d36.... hash

screen shot 2018-03-26 at 9 33 20 am

screen shot 2018-03-26 at 9 30 44 am

screen shot 2018-03-26 at 9 30 54 am

@AirWick219
Copy link
Author

Weird ... You can close this ... While preparing a example repo .. It magically works and the extra json is not there anymore which does not cause the 404.

But in order to prevent the page refresh. I have to add the following code in my root level component to remount the latest module since I am using react-rails.

components/Base.jsx

if (module.hot) {
  module.hot.accept('./Management', () => {
    ReactRailsUJS.mountComponents();
  });
}

Otherwise, I would get an error in the dev-server

Aborted because ./app/javascript/components/Management.jsx is not accepted

Since webpacker has a issue going on to restrict using webpack-dev-server 3+
#1303 . so not sure if that's something that would go away with webpack-dev-server 3+

@gauravtiwari
Copy link
Member

Great 👍 going to close this one for now.

@ahmadasaad89
Copy link

I have this exact problem, HMR is looking for a different hash than the one generated on recompile, any ideas why is this happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants