GoogleChrome / workbox

📦 Workbox: JavaScript libraries for Progressive Web Apps
https://developers.google.com/web/tools/workbox/
MIT License
12.27k stars 805 forks source link

uncaughtPromiseRejection causing webpack to hang #687

Closed gdborton closed 7 years ago

gdborton commented 7 years ago

Library Affected: workbox-webpack-plugin

Browser & Platform: OSX, node v6.10.2, npm v2.15.12

Issue or Feature Request Description:

Including this plugin in our webpack config w/ webpack's node api prevents surfacing build errors and results in hung builds when errors are present. Using a config like so...

const webpack = require('webpack');
const config = require('./myWebpackConfigWithWorkbox');

const compiler = webpack(config);
compiler.run(() => {
  throw new Error('this should cause the program to exit 1');
});

^ this config results in our compile script never exiting and a message about an unhandled rejection. Removing workbox-webpack-plugin makes the script behave as expected. As a short term work around for this we've included the below snippet.

process.on('unhandledRejection', (reason) => {
  console.log('Found an unhandled promise rejection. Rethrowing to surface the error.');
  throw reason;
});

Let me know if this isn't enough information to reproduce and I'll throw up a repo that demonstrates the problem.

prateekbh commented 7 years ago

@gdborton, any stack trace and your webpack version would be really helpful

gdborton commented 7 years ago

@prateekbh I'm afraid that the stack trace wouldn't be very helpful.

/Users/gary_borton/airlab/repos/airbnb/webpack/compile.js:50
  throw reason;
  ^

Error: asdf
    at multiCompiler.run (/Users/gary_borton/airlab/repos/airbnb/webpack/compile.js:22:9)
    at runWithDependencies (/Users/gary_borton/airlab/repos/airbnb/node_modules/webpack/lib/MultiCompiler.js:153:19)
    at /Users/gary_borton/airlab/repos/airbnb/node_modules/webpack/node_modules/async/dist/async.js:1074:9
    at /Users/gary_borton/airlab/repos/airbnb/node_modules/webpack/node_modules/async/dist/async.js:421:16
    at iteratorCallback (/Users/gary_borton/airlab/repos/airbnb/node_modules/webpack/node_modules/async/dist/async.js:996:13)
    at /Users/gary_borton/airlab/repos/airbnb/node_modules/webpack/node_modules/async/dist/async.js:906:16
    at /Users/gary_borton/airlab/repos/airbnb/node_modules/webpack/node_modules/async/dist/async.js:1071:13
    at fn (/Users/gary_borton/airlab/repos/airbnb/node_modules/webpack/lib/MultiCompiler.js:99:21)
    at compiler.run (/Users/gary_borton/airlab/repos/airbnb/node_modules/webpack/lib/MultiCompiler.js:148:20)
    at /Users/gary_borton/airlab/repos/airbnb/node_modules/webpack/lib/Compiler.js:250:22

I've gotten this issue with workbox-webpack-plugin @1.0.0 and @1.1.0 and with webpack @2.3.2 and 3.1.0

While trying to create a repo to reproduce the problem, I noticed that it only seems to happen in conjunction with our use of happypack. Removing either happypack or this plugin makes the issue go away.

gdborton commented 7 years ago

Ooph seems even more complicated than that, we've also got SWPrecache and disabling any of these three plugins makes the build exit with an error code as expected... If I had to guess I'd say this is an issue with happypack, but haven't yet been able to reproduce in a small repo.

jeffposnick commented 7 years ago

Closing for now. Please reopen if you have clear reproduction steps or a better idea or what's going on.