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

ModuleNotFoundError not being handled #214

Closed
gringocl opened this issue Jan 25, 2017 · 4 comments · Fixed by #262
Closed

ModuleNotFoundError not being handled #214

gringocl opened this issue Jan 25, 2017 · 4 comments · Fixed by #262

Comments

@gringocl
Copy link

BEFORE YOU SUBMIT please read the following:

I'm submitting a bug report

Webpack version:
2.2.0

Webpack Karma version:
2.0.1

Karma version:
1.4

Please tell us about your environment:
OSX 10.x

Browser: [Phantom 2.1.1]

Current behavior:
If a misspelled module is imported in a test the following stacktrace is emitted:

23 01 2017 07:27:18.606:ERROR [karma]: TypeError: Cannot read property 'addChunk' of null
  at self.preparedChunks.forEach.preparedChunk (/Path/to/code/node_modules/webpack/lib/Compilation.js:526:10)
  at Array.forEach (native)
  at Compilation.seal (/Path/to/code/node_modules/webpack/lib/Compilation.js:519:23)
  at /Path/to/code/node_modules/webpack/lib/Compiler.js:474:16
  at /Path/to/code/node_modules/tapable/lib/Tapable.js:225:11
  at done (/Path/to/code/node_modules/karma-webpack/node_modules/async/lib/async.js:132:19)
  at /Path/to/code/node_modules/karma-webpack/node_modules/async/lib/async.js:32:16
  at Plugin.<anonymous> (/Path/to/code/node_modules/karma-webpack/lib/karma-webpack.js:175:7)
  at _addModuleChain (/Path/to/code/node_modules/webpack/lib/Compilation.js:443:12)
  at processModuleDependencies.err (/Path/to/code/node_modules/webpack/lib/Compilation.js:420:14)
  at finalCallbackAddModuleDependencies (/Path/to/code/node_modules/webpack/lib/Compilation.js:330:12)
  at /Path/to/code/node_modules/async/dist/async.js:356:16
  at iteratorCallback (/Path/to/code/node_modules/async/dist/async.js:934:13)
  at /Path/to/code/node_modules/async/dist/async.js:840:16
  at finalCallbackAddModuleDependencies (/Path/to/code/node_modules/webpack/lib/Compilation.js:330:12)
  at /Path/to/code/node_modules/async/dist/async.js:356:16

Expected/desired behavior:

Something similar to this, and not having to restart the test runner would be great!
Currently our setup has bail: true and this doesn't give me my expected result but at least this error message is much better.

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  Error: Cannot find module "foo"
  at test/index.js:183490
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 0 of 0 ERROR (1.898 secs / 0 secs)
  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.

it seems that the callback being called here mostly for success cases:
https://github.com/webpack-contrib/karma-webpack/blob/v2/src/karma-webpack.js#L167

compilation.addEntry('', dep, path.relative(this.basePath, file).replace(/\\/g, '/'), function() {
      \\ success case
      callback()
}.bind(this))

needs to be called with an err.

compilation.addEntry('', dep, path.relative(this.basePath, file).replace(/\\/g, '/'), function(err) {
     if (err) {
        return callback(err);
     }
      \\ success case
      callback()
}.bind(this))
@gringocl
Copy link
Author

Any opinions / thoughts on this?

@davidgoli
Copy link

@d3viant0ne any thoughts here? this would be super helpful to get merged as existing error messages are cryptic and misleading.

@joshwiens
Copy link
Contributor

There was a bit of discussion on how to fix this without breaking things for the angular/cli users, that particular integration is no longer an issue.

I'm in the middle of rewriting karma-webpack to close out some of the long standing features, i'll get a quick fix in to deal with the error messages in the current major this weekend.

@neutraali
Copy link

I can't get proper error messages with or without bail; I keep getting the "Cannot read property 'addChunk' of null" -error. It works with with one codebase, but doesn't with the other. More descriptive error messages would be much appreciated.

"webpack": "2.4.1",
"karma-webpack": "2.0.3"

jonyeezs added a commit to jonyeezs/PiggyMonitor that referenced this issue Jun 9, 2017
@joshwiens joshwiens removed their assignment Aug 18, 2017
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.

4 participants