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

writeToDisk leads the compile time keep increasing. #469

Closed
unbug opened this issue Sep 23, 2019 · 9 comments · Fixed by #472
Closed

writeToDisk leads the compile time keep increasing. #469

unbug opened this issue Sep 23, 2019 · 9 comments · Fixed by #472

Comments

@unbug
Copy link

unbug commented Sep 23, 2019

  • Operating System: MacOS 10.15
  • Node Version: v10.15.2
  • NPM Version: 6.11.3
  • webpack Version: 4.40.2
  • webpack-dev-middleware Version: 3.8.1

Expected Behavior

The compile-time should not keep increasing.

Actual Behavior

The compile-time keep increasing, and log shows duplicate write to disk keep increasing.
e.g. First compile:

[16:31:46] ➤ 「wdm」: Asset written to disk: app/js/app.js
writeToDisk
[16:31:46] ➤ 「wdm」: Asset written to disk: app/js/app.js.map
writeToDisk
[16:31:46] ➤ 「wdm」: Asset written to disk: app/js/app.js
[16:31:46] ➤ 「wdm」: Asset written to disk: app/js/app.js.map

Third compile:

[16:33:01] ➤ 「wdm」: Asset written to disk: app/js/app.js
writeToDisk
[16:33:01] ➤ 「wdm」: Asset written to disk: app/js/app.js.map
writeToDisk
[16:33:01] ➤ 「wdm」: Asset written to disk: app/js/app.js
writeToDisk
[16:33:01] ➤ 「wdm」: Asset written to disk: app/js/app.js.map
writeToDisk
[16:33:01] ➤ 「wdm」: Asset written to disk: app/js/app.js
writeToDisk
[16:33:01] ➤ 「wdm」: Asset written to disk: app/js/app.js
[16:33:01] ➤ 「wdm」: Asset written to disk: app/js/app.js.map
writeToDisk
[16:33:01] ➤ 「wdm」: Asset written to disk: app/js/app.js.map

Code

          webpackDevMiddleware(compiler, {
            publicPath: webpackConfig.dev.output.publicPath,
            stats: { colors: true },
            writeToDisk: true,
            logTime: true,
            logLevel: 'debug'
          }),

How Do We Reproduce?

I think to change the logLevel to debug will see the log for any project.

@alexander-akait
Copy link
Member

Thanks for issue 👍

@unbug
Copy link
Author

unbug commented Sep 25, 2019

Looks like the compiler.hooks.assetEmitted.tapAsync('WebpackDevMiddleware', .... got duplicate called for each compile.
https://github.com/webpack/webpack-dev-middleware/blob/master/lib/fs.js#L18

@alexander-akait
Copy link
Member

@unbug yep, in my todo, will be fixed in near future

@alexander-akait
Copy link
Member

@unbug hm, can you create minimum reproducible test repo?

@alexander-akait
Copy link
Member

No need, find memory leak, WIP

@JulienPradet
Copy link

Hi @evilebottnawi

Is the memory leak you are talking about is that the first hook creates a new one on each pass, leading to never GC the compilation object?

I was myself investigating issues with webpack-dev-middleware and was about to submit a PR about this. (found it thanks to this clue: webpack/webpack#6929 (comment)). But I'm wondering if that would be useful to you reading your last comment.

@alexander-akait
Copy link
Member

@JulienPradet yes, here same bug, on each compilation we create new callback on hook, so after 100 compilations we have 100 callbacks. Here memory leak. I added this to my todo list, try to throw warning on webpack side for webpack@5, it is allow catch all these cases.

@JulienPradet
Copy link

That would be awesome!
If you need help landing the fix in webpack-dev-middleware (for example if you don't have time), I would be happy to help :)

@alexander-akait
Copy link
Member

@JulienPradet thanks, i am working on this right now, so I think there’s no point in working together on this, anyway thanks for feedback

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

Successfully merging a pull request may close this issue.

3 participants