django-webpack / webpack-bundle-tracker

Spits out some stats about webpack compilation process to a file
MIT License
268 stars 107 forks source link

using getter to access error message #103

Closed vinojv closed 3 years ago

vinojv commented 3 years ago

https://github.com/vinojv/webpack-bundle-tracker/blob/master/lib/index.js#L132 breaks in circleci since error is undefined.

Screenshot 2021-08-05 at 12 47 50 PM

you can replicate the error by using worker-loader and webworker

fjsj commented 3 years ago

@vinoj thanks for the PR. Could you please give more context on how to reproduce this issue?

amw commented 3 years ago

I ran into the same issue. I'm also using a package similar to worker-loader which runs a child compilation.

[webpack-cli] TypeError: Cannot read property 'message' of undefined
    at BundleTrackerPlugin._handleDone (/Users/amw/Apple/ap-service/node_modules/webpack-bundle-tracker/lib/index.js:134:33)
    at Hook.eval [as callAsync] (eval at create (/Users/amw/Apple/ap-service/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/amw/Apple/ap-service/node_modules/tapable/lib/Hook.js:18:14)
    at onCompiled (/Users/amw/Apple/ap-service/node_modules/webpack/lib/Compiler.js:440:21)
    at /Users/amw/Apple/ap-service/node_modules/webpack/lib/Compiler.js:1118:17
    at Hook.eval [as callAsync] (eval at create (/Users/amw/Apple/ap-service/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/amw/Apple/ap-service/node_modules/tapable/lib/Hook.js:18:14)
    at /Users/amw/Apple/ap-service/node_modules/webpack/lib/Compiler.js:1114:33
    at finalCallback (/Users/amw/Apple/ap-service/node_modules/webpack/lib/Compilation.js:2256:11)
    at /Users/amw/Apple/ap-service/node_modules/webpack/lib/Compilation.js:2547:11

But I don't think this PR is correct. Instead of using get we should try to find the error traversing compilation.children. Just like the Stats.hasErrors method does: https://github.com/webpack/webpack/blob/c181294865dca01b28e6e316636fef5f2aad4eb6/lib/Stats.js#L45

fjsj commented 3 years ago

Superseded by https://github.com/django-webpack/webpack-bundle-tracker/pull/107 Thanks