webpack-dev-server: Browser reloads infinitely when using multi-compiler mode
- This is a bug
- This is a modification request
Code
See full example repository for reproduction here
// webpack.config.js
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
module.exports = [
{
mode: 'development',
entry: './temp2.js',
output: {
filename: 'main2.js',
path: path.resolve(__dirname, 'dist'),
},
plugins: [
new HtmlWebpackPlugin(),
],
},
{
mode: 'development',
entry: './temp.js',
output: {
filename: 'main1.js',
path: path.resolve(__dirname, 'dist'),
},
},
];
Please paste the results of npx webpack-cli info
here, and mention other relevant information
System:
OS: macOS 11.5.2
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 5.88 GB / 32.00 GB
Binaries:
Node: 16.8.0 - /usr/local/bin/node
npm: 7.21.0 - /usr/local/bin/npm
Browsers:
Chrome: 92.0.4515.159
Firefox: 91.0.2
Safari: 14.1.2
Packages:
html-webpack-plugin: ^5.3.2 => 5.3.2
webpack: ^5.52.0 => 5.52.0
webpack-cli: ^4.8.0 => 4.8.0
webpack-dev-server: ^4.1.0 => 4.1.0
Expected Behavior
I’m expecting the page not to reload infinitely. If my configuration is not correct, I would like for webpack to tell me that in some way.
Actual Behavior
The page reloads in an infinite loop. I could extract the console output from Firefox. The following output is the only output in the console and happens before the reload is triggered:
[HMR] Cannot find update. Need to do a full reload! log.js:26:12
[HMR] (Probably because of restarting the webpack-dev-server) log.js:26:12
Important
It is important to note that this behaviour is not triggered in 100% of the cases. For me it roughly triggers in 1/3 of the cases, when using a more complex configuration (in the project I encountered this in), it’s almost every time).
For Bugs; How can we reproduce the behavior?
Please see https://github.com/chmanie/webpack-hmr-bug to find information on how to reproduce the bug (it’s quite easy).
For Features; What is the motivation and/or use-case for the feature?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 62 (57 by maintainers)
@alexander-akait can confirm it’s working with the new release. Thanks for getting this out so fast and for the support!
Found a problem, why we do not reload, WIP, maybe do release today
@koggdal I think this problem in other place, please open an new issue tomorrow with example, logic for hot/reload not connected in any way with
Disconnected
, maybe you browser was open too fast and server is not ready yet, so web socket server try to connect, but server is still starting@alexander-akait with both #3840 and #3841 it seems all is working!
We can fix it just adding
isRecompiling
check and do not output unnecessary logsHappy to test out whatever change locally if helpful, just @ me 😄
Awesome, looking forward to it! Thanks for looking into this 🙏
I will try to fix multi compiler issues on the next week, also try to add support for multiple dev servers, a lot of tasks, sorry for delay
@alexander-akait here is a more simplified reproduction: https://github.com/DylanPiercey/webpack-dev-server-issue-infinite-reload
Sorry, replying with code snippets via mobile is hard -_-. I updated the previous comment with the correct command.
@alexander-akait ill make a simpler reproduction, but if you want to test quickly our Marko webpack example repo has this issue.
npm init marko -- --template webpack-express
. Thennpm run dev
and editsrc/pages/index/index.marko
.I’ll be downgrading this example today, and I’ll also create a more simplified reproduction. Will share once I have