webpack-dev-server icon indicating copy to clipboard operation
webpack-dev-server copied to clipboard

Webpack hangs indefinitely when a plugin throws an error in `done` hook

Open webpack-bot opened this issue 7 years ago • 6 comments

Bug report

What is the current behavior? When using webpack in development mode with either webpack-dev-server or webpack-serve a plugin may throw an error in the done hook. When this happens, there is no indication this error has occurred and compilation halts. It is also not possible to see what the error is. It seems like the done hook does not get called for any plugins that are later in the plugin list so they have no way of reporting the error.

If the current behavior is a bug, please provide the steps to reproduce. I set up a repository with a minimal reproduction: https://github.com/robrichard/webpack-repro

What is the expected behavior? Webpack should log the errors or pass them to later plugins

Other relevant information: webpack version: 4.21.0 Node.js version: 8.9.3 Operating System: macOS 10.13.6 Additional tools:


This issue was moved from webpack/webpack#8234 by @ooflorent. Original issue was by @robrichard.

webpack-bot avatar Nov 02 '18 11:11 webpack-bot

@evilebottnawi why do you think this is a wds/wdm issue and not a webpack issue?

I looked into this and it seems like this is an issue with the watcher in Webpack.

If a plugin throws an error in the done hook in watch mode, webpack emits the chunk but never taps done. This causes wdm to not properly exit/error and it just gets stuck waiting for done to tap.

I've better reproduced this issue here: https://github.com/lukebro/webpack-issue-8234

The output when running this is:

watchRun
normalModuleFactory
contextModuleFactory
beforeCompile
compile
thisCompilation
compilation
make
afterCompile
shouldEmit
emit
afterEmit
err: null stats.hasErrors(): false

If you update index.js after, it invalidates and rerun's but again never taps done.

Calling this same webpack config without watcher (just compiler.run) you will get the run callback called with the correct error thrown.

I'm not 100% if this is intended or what. But this issue can be reproduced without wds/wdm.

lukebro avatar Feb 14 '19 06:02 lukebro

I'm not 100% if this is intended or what. But this issue can be reproduced without wds/wdm.

Can you create minimum reproducible test repo?

alexander-akait avatar Feb 14 '19 09:02 alexander-akait

@evilebottnawi yes the repo is here: https://github.com/lukebro/webpack-issue-8234

lukebro avatar Feb 14 '19 13:02 lukebro

/cc @ooflorent

alexander-akait avatar Feb 14 '19 13:02 alexander-akait

We need recreate issue in webpack itself, problem not related to webpack-dev-server

alexander-akait avatar May 28 '19 13:05 alexander-akait

Any updates on this. I'm trying to use newer versions of a few plugins in webpack and when I update one, I can't start the dev server due to hanging.

wdfinch avatar Feb 23 '22 00:02 wdfinch

Fixed in webpack@5

alexander-akait avatar Feb 08 '24 13:02 alexander-akait