question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Infinite rebuild loop in vagrant environment in watch mode

See original GitHub issue

Bug report

What is the current behavior? Using Webpack 5.11.1 (update from 4) inside a vagrant machine on macOS i have a loop of rebuild in watch mode, for example:

  • starting the client:watch with npx webpack --devtool eval-source-map --config webpack.client.js --watch
  • first build works
  • start a lot of rebuild because inside the compiler.removedFiles variables found the /src/common/js/modules path that is not really deleted from fs

If the current behavior is a bug, please provide the steps to reproduce.

this is our configuration:

{
  mode: 'development',
  target: 'web',
  watchOptions: { poll: 500, ignored: [ 'public', 'build' ] },
  watch: true,
  devtool: false,
  entry: {
    'bundle.0.0.1': [
      '/var/www/hs-goldenrod/wls/PROJECTNAME/src/js/client.js'
    ]
  },
   resolve: {
    extensions: [ '.js', '.jsx', '.scss', '.css' ],
    alias: {
      'module-analytics': '/var/www/PROJECTNAME/src/packages/module-analytics',
      ...
    },
    fallback: {
      fs: false,
      net: false,
      tls: false,
      console: false,
      child_process: false,
      path: '/node_modules/path-browserify/index.js',
      crypto: '/node_modules/crypto-browserify/index.js',
      stream: '/node_modules/stream-browserify/index.js',
      https: '/node_modules/https-browserify/index.js',
      http: '/node_modules/stream-http/index.js',
      zlib: '/node_modules/browserify-zlib/lib/index.js'
    }
  },
   output: {
    path: 'public/js',
    publicPath: '/js/',
    filename: '[name].min.js',
    chunkFilename: '[name].0.0.1.min.js'
  },
  node: {},
  optimization: { splitChunks: { cacheGroups: [Object] }, minimize: true }

the deleted and changed file list is printed by an our Webpack plugin

class WatchRunPlugin {
  // Define `apply` as its prototype method which is supplied with compiler as its argument
  apply(compiler) {
    // Specify the event hook to attach to
    compiler.hooks.watchRun.tap("WatchRunPlugin", (comp) => {
      if (comp.modifiedFiles) {
        const changedFiles = Array.from(
          comp.modifiedFiles,
          (file) => `\n  ${file}`
        ).join("");
        console.log("\n===============================");
        console.log("FILES CHANGED:", changedFiles);
        console.log("===============================");
      }
      if (comp.removedFiles) {
        const removedFiles = Array.from(
          comp.removedFiles,
          (file) => `\n  ${file}`
        ).join("");
        console.log("\n===============================");
        console.log("FILES REMOVED:", removedFiles);
        console.log("===============================");
      }
    });
  }
}

module.exports = () => {
  return new WatchRunPlugin();
};

and this is a example prompt

[webpack-cli] watching files for updates...
3% setup watch run webpack-cli[webpack-cli] Compilation starting...
3% setup watch run WatchRunPlugin
===============================
FILES CHANGED:
  /var/www/hs-goldenrod/wls/PROJECTNAME/src/common/js/server.js
===============================

===============================
FILES REMOVED:
===============================
99% done plugins webpack-cli[webpack-cli] Compilation finished
asset server.bundle.js 24.9 MiB [emitted] (name: server)
asset PropertyOverlay.bundle.js 100 KiB [emitted] (name: PropertyOverlay)
asset DetailsOverlay.bundle.js 96.9 KiB [emitted] (name: DetailsOverlay)
asset AmenitiesFilter.bundle.js 46.1 KiB [emitted] (name: AmenitiesFilter)
asset ReviewsOverlay.bundle.js 32.5 KiB [emitted] (name: ReviewsOverlay)
orphan modules 3.07 MiB [orphan] 542 modules
runtime modules 4.07 KiB 12 modules
javascript modules 7.36 MiB
  modules by path ./node_modules/ 3.69 MiB 623 modules
  modules by path ./src/ 3.66 MiB
    modules by path ./src/packages/ 2.89 MiB 171 modules
    modules by path ./src/common/js/ 789 KiB
      cacheable modules 788 KiB 2 modules
      2 modules
json modules 495 KiB
  modules by path ./node_modules/har-schema/lib/*.json 6.93 KiB 18 modules
  modules by path ./node_modules/iconv-lite/encodings/tables/*.json 86.7 KiB 8 modules
  modules by path ./node_modules/encoding/node_modules/iconv-lite/encodings/tables/*.json 86.7 KiB 8 modules
  modules by path ./node_modules/ajv/lib/refs/*.json 5.58 KiB 3 modules


webpack 5.11.1 compiled with 1 warning in 21320 ms
[webpack-cli] watching files for updates...
3% setup watch run webpack-cli[webpack-cli] Compilation starting...
3% setup watch run WatchRunPlugin
===============================
FILES CHANGED:
===============================

===============================
FILES REMOVED:
  /var/www/hs-goldenrod/wls/PROJECTNAME/src/common/js/modules
===============================
99% done plugins webpack-cli[webpack-cli] Compilation finished
asset server.bundle.js 24.9 MiB [emitted] (name: server)
asset PropertyOverlay.bundle.js 100 KiB [emitted] (name: PropertyOverlay)
asset DetailsOverlay.bundle.js 96.9 KiB [emitted] (name: DetailsOverlay)
asset AmenitiesFilter.bundle.js 46.1 KiB [emitted] (name: AmenitiesFilter)
asset ReviewsOverlay.bundle.js 32.5 KiB [emitted] (name: ReviewsOverlay)
orphan modules 3.07 MiB [orphan] 542 modules
runtime modules 4.07 KiB 12 modules
javascript modules 7.36 MiB
  modules by path ./node_modules/ 3.69 MiB 623 modules
  modules by path ./src/ 3.66 MiB
    modules by path ./src/packages/ 2.89 MiB 171 modules
    modules by path ./src/common/js/ 789 KiB
      cacheable modules 788 KiB 2 modules
      2 modules
json modules 495 KiB
  modules by path ./node_modules/har-schema/lib/*.json 6.93 KiB 18 modules
  modules by path ./node_modules/iconv-lite/encodings/tables/*.json 86.7 KiB 8 modules
  modules by path ./node_modules/encoding/node_modules/iconv-lite/encodings/tables/*.json 86.7 KiB 8 modules
  modules by path ./node_modules/ajv/lib/refs/*.json 5.58 KiB 3 modules
webpack 5.11.1 compiled with 1 warning in 18108 ms

In the first case the rebuild is correct because the edit of the /var/www/hs-goldenrod/wls/PROJECTNAME/src/common/js/server.js file was made by me

but in the second case the rebuild is wrong because nobody delete the folder /var/www/hs-goldenrod/wls/PROJECTNAME/src/common/js/modules and in the fs the folder is present and not touched

In fact the wrong rebuild is not just one but go in a infinite loop that have always the /var/www/hs-goldenrod/wls/PROJECTNAME/src/common/js/modules path inside the deletedFiles

What is the expected behavior?

just rebuild if a file is changed and not if a folder that is not deletes is in deleted list

Other relevant information: webpack version: 5.11.1 Node.js version: v12.13.1 Operating System: vagrant machine with Debian

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
sokracommented, Jan 7, 2021

There is a difference how webpack 4 and 5 handle watching of non-existing files. These invalid paths are treated as non-existing (since fs calls fail).

1reaction
sokracommented, Jan 7, 2021

importers probably would need to ability to provide their own includedFiles as result.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stopping an infinite loop process in vagrant - laravel
The ideal way to solve this would be to fix that code that creates the infinite loop. You could kill the process on...
Read more >
Rebuild an Environment | Vagrant
To start a box, run vagrant up . That's it! Since the Vagrant environment is already all configured via the Vagrantfile, you or...
Read more >
Vagrant Crash Course - YouTube
In this crash course we will dive into Vagrant which is used to create isolated & portable development environments. We will go into...
Read more >
7b26886cf52c850ec0a3..
Resolves: rhbz#1961492 - bz1965862 - A recent Coverity change can cause an infinit loop on map reload - fix lookup_prune_one_cache() refactoring change.
Read more >
20 Forgotten Games From The 90s Worth Digging Up
Discworld required that gamers explore the environment for clues to progress in the game. Though the plot and graphics were well-done, gamers complained ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found