Skip to content

Browser reloads infinitely when using multi-compiler mode #3803

Closed
@chmanie

Description

@chmanie
  • 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions