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

Fatal error: Cannot read property 'rawRequest' of undefined #5

Closed
grrowl opened this issue Mar 15, 2015 · 10 comments
Closed

Fatal error: Cannot read property 'rawRequest' of undefined #5

grrowl opened this issue Mar 15, 2015 · 10 comments
Assignees
Labels

Comments

@grrowl
Copy link

grrowl commented Mar 15, 2015

Fatal error: Cannot read property 'rawRequest' of undefined
TypeError: Cannot read property 'rawRequest' of undefined
    at WebpackNotifierPlugin.compileMessage (/Users/tom/Documents/magicland/auth.comet.is/node_modules/webpack-notifier/index.js:29:31)
    at WebpackNotifierPlugin.compilationDone (/Users/tom/Documents/magicland/auth.comet.is/node_modules/webpack-notifier/index.js:39:20)
    at Tapable.applyPlugins (/Users/tom/Documents/magicland/auth.comet.is/node_modules/webpack/node_modules/tapable/lib/Tapable.js:26:37)
    at Tapable.<anonymous> (/Users/tom/Documents/magicland/auth.comet.is/node_modules/webpack/lib/Compiler.js:191:12)
    at FSReqWrap.oncomplete (fs.js:99:15)

Added simply with plugins: [ new WebpackNotifierPlugin({title: 'server build'}) ]

@Turbo87
Copy link
Owner

Turbo87 commented Mar 16, 2015

looks like error.module is undefined. can you reproduce that error?

@Turbo87 Turbo87 added the bug label Mar 16, 2015
@Turbo87 Turbo87 self-assigned this Mar 16, 2015
@grrowl
Copy link
Author

grrowl commented Mar 19, 2015

It took me a second, but yes! I'm building two entry points concurrently, with something similar to the below Gruntfile setup. I don't think grunt-concurrent does "real" process forking to achieve this so it might be clobbering a static variable somewhere within webpack:

'use strict';

module.exports = function (grunt) {

  var webpackConfig = require('./webpack.config.js');

  // Load all available grunt- npm tasks
  require('matchdep').filterAll('grunt-*').forEach(grunt.loadNpmTasks);

  grunt.initConfig({

    // Webpack task to compile assets to dist/
    webpack: {
      options: {},
      'client-prod': webpackConfig(['client']),
      'server-prod': webpackConfig(['server'])
    },

    // Tasks for compiling the app concurrently (output may be a bit messy)
    concurrent: {
      'compile-prod': {
        tasks: ['webpack:server-prod', 'webpack:client-prod'],
        options: {logConcurrentOutput: true}
      }
    }
  });

  grunt.registerTask('build:prod', function () {
    grunt.task.run([
      'concurrent:compile-prod',
    ]);
  });

};

@grrowl
Copy link
Author

grrowl commented Mar 19, 2015

The above cut-down config actually works as grunt build:prod, so it must be one of the removed tasks. I'll dig into it tomorrow and follow-up.

@Turbo87
Copy link
Owner

Turbo87 commented Mar 19, 2015

@grrowl it would be awesome if you could modify https://github.com/Turbo87/webpack-notifier/tree/master/example to reproduce this.

@AndrewRayCode
Copy link

I also hit this on a very large build. Copying from webpack/webpack#930

full stack trace:

$ webpack -p

    ./node_modules/webpack-notifier/index.js:29
        var message = error.module.rawRequest;
                                ^
    TypeError: Cannot read property 'rawRequest' of undefined
        at WebpackNotifierPlugin.compileMessage (./node_modules/webpack-notifier/index.js:29:31)
        at WebpackNotifierPlugin.compilationDone (./node_modules/webpack-notifier/index.js:39:20)
        at Tapable.applyPlugins (./node_modules/webpack/node_modules/tapable/lib/Tapable.js:26:37)
        at Tapable.<anonymous> (./node_modules/webpack/lib/Compiler.js:189:12)
        at Tapable.emitRecords (./node_modules/webpack/lib/Compiler.js:277:37)
        at Tapable.<anonymous> (./node_modules/webpack/lib/Compiler.js:183:11)
        at ./node_modules/webpack/lib/Compiler.js:270:11
        at Tapable.applyPluginsAsync (./node_modules/webpack/node_modules/tapable/lib/Tapable.js:60:69)
        at Tapable.afterEmit (./node_modules/webpack/lib/Compiler.js:267:8)
        at Tapable.<anonymous> (./node_modules/webpack/lib/Compiler.js:262:14)

Plugins list:

plugins: [
    new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery'
    }),
    new WebpackNotifierPlugin(),
    new webpack.optimize.UglifyJsPlugin({
        compress: {
            warnings: false
        }
    })
]

When I remove the notifier, I get a very large amount of warnings from uglify, which might be related?

$ webpack -p

    Hash: 8b99c30c6cfe657f0be5
    Version: webpack 1.6.0
    Time: 49426ms
        Asset     Size  Chunks             Chunk Names
    bundle.js  1419317       0  [emitted]  main
        + 330 hidden modules

    WARNING in bundle.js from UglifyJs

(616 warnings follow)

@zachwood
Copy link

Same issue as @delvarworld, if I have Uglify warnings I get the error:

TypeError: Cannot read property 'rawRequest' of undefined

If uglification is skipped (and thus no warning output), everything works as expected.

@AndrewRayCode
Copy link

FYI, the workaround I did this is that for prod builds, I run the webpack task with NODE_ENV=production and in webpack.config.js build the plugin list dynamically based on if process.env.NODE_ENV === 'production' . If it's true I add Uglify plugin, otherwise I add Notifier plugin. You probably shouldn't be uglifying in dev and you shouldn't be notifying in production, so this works well for me.

@grrowl
Copy link
Author

grrowl commented Apr 16, 2015

Sorry I never followed up on this — been swamped and have moved away from including this for now (other devs found it noisy)

@Turbo87
Copy link
Owner

Turbo87 commented Apr 16, 2015

I just pushed a fix for this issue and released it as v1.2.1. Please check if this issue is resolved for you now and let me know if there are still problems.

@zachwood
Copy link

Working great for me. Thanks!

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

No branches or pull requests

4 participants