google/closure-compiler-js

ICE when compiling 'bson' module

jbemmel opened this issue · 3 comments

One of my apps has the 'bson' npm package installed, and the compiler produces an ICE when processing it:

[09:55:15] Starting 'bug'...
/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:4429
function yEb(b){var c;try{return b.Rh()}catch(a){a=Rgb(a);if(iL(a,71)){c=a;throw Sgb(new oJ(c))}else throw Sgb(a)}}
^

Error: java.lang.RuntimeException: java.lang.RuntimeException: INTERNAL COMPILER ERROR. Please report this problem. (TypeError) : Cannot read property 'b' of null Node(NAME Double): node_modules/bson/alternate_parsers/bson.js:2:4 , Double = require('../lib/bson/double').Double Parent(VAR): node_modules/bson/alternate_parsers/bson.js:1:0 var Long = require('../lib/bson/long').Long
at oJ.MG [as Mf] (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:7504:21518)
at oJ.PG [as Of] (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:7504:21719)
at oJ (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:3438:76)
at yEb (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:4429:86)
at zCb (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:6191:93)
at e4c (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:7131:349)
at DJ (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:1729:29)
at GJ (/usr/lib/node_modules/google-closure-compiler-js/jscomp.js:3005:44)
at /usr/lib/node_modules/google-closure-compiler-js/jscomp.js:3179:46
at module.exports (/usr/lib/node_modules/google-closure-compiler-js/compile.js:31:15)
at CompilationStream._flush (/usr/lib/node_modules/google-closure-compiler-js/lib/gulp.js:97:22)
at CompilationStream. (_stream_transform.js:118:12)
at CompilationStream.g (events.js:292:16)
at emitNone (events.js:86:13)
at CompilationStream.emit (events.js:185:7)
at prefinish (_stream_writable.js:505:12)
at finishMaybe (_stream_writable.js:513:7)
at endWritable (_stream_writable.js:525:3)
at CompilationStream.Writable.end (_stream_writable.js:490:5)
at DestroyableTransform.onend (/tmp/ov/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:523:10)
at DestroyableTransform.g (events.js:292:16)
at emitNone (events.js:91:20)
at DestroyableTransform.emit (events.js:185:7)
at /tmp/ov/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:965:16
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)

npm list -g | grep goo
├─┬ google-closure-compiler-js@20161201.0.0

gulpfile to reproduce:

const gulp = require('gulp');
const compiler = require('google-closure-compiler-js').gulp();

gulp.task('bug', function() {
  return gulp.src( [ "node_modules/bson/**/*.js" ], {base: './'})
      // your other steps here
      .pipe(compiler({
          compilationLevel: 'SIMPLE',
          warningLevel: 'VERBOSE',
          processCommonJsModules: true,
          outputWrapper: '(function(){\n%output%\n}).call(this)',
          jsOutputFile: 'output.min.js',  // outputs single file
          createSourceMap: true,
        }))
      .pipe(gulp.dest('./build'));
});

Checking to see if this happens with the Java version too in which case it's just a bug in the compiler, and we should get a more readable stack trace.

Seems to not happen with the Java version. @Dominator008 or @samthor do you know how to build a non-obfuscated version of the GWT build so that the stack trace we get is readable?

Using 20170124.0.0 it didn't crash for me, but also didn't compile because the module resolution wasn't working. I'll try again once 20170218.0.0 is published.

@MatrixFrog You'd need to add

<optimize>0</optimize>

to
https://github.com/google/closure-compiler/blob/f21c592ef37c71f39f98d7d18ebb59c618f4f420/pom-gwt.xml#L254
for a non-optimized version.