1

This has happened for the second time now and as you can imagine, a debugger that shows wrong information is the worst thing that can happen when debugging. What happens is that when using source maps that debugger thinks the VM is at a certain line, but actually it's not yet there, or worse, will never reach this line. The source maps are generated with the Grunt uglify plugin, which uses UglifyJS2.

An example:

if(something === 1){
    console.log("it's something"); // debugger thinks the VM is here
else{
    console.log("no it's not");    // while actually it's here
}

This did then print no it's not although the debugger jumped into the if

The other example I experienced was:

var that = this;
some.functionCall(1, function(){
    console.log(that);  //this is where the debugger thinks the vm is
    // debugger: that = undefined
    // console prints nothing to that point
});

When I continued the program the console.log(that) did fire eventually.

Did anyone else experience the same problem? Is it more likely a problem of UglifyJS2 or of Google Chrome?

Chrome Version: 38.0.2125.8 dev (64-bit)
Uglify2JS: 2.4.0
grunt-contrib-uglify: 0.5.1

rob
  • 2,498
  • 5
  • 20
  • 37

1 Answers1

1

I observe similar issue. The offset is equal exactly to number of comment lines.

EDIT The root cause occured to be lines prefixed with //>> which occured in 3rd party libraries. Every such a line makes 1 line offset. They seem to be some depreciated requirejs build pragmas.

For us the solution was to find&replace them in the code on the build time, as we do not use pragmas in our build system.

sed -i -e 's_//>>_// pragma was here: _g' `find . -type f -name "*.js"`
Alek Kowalczyk
  • 584
  • 4
  • 15
  • The question is whether it's a chrome or an uglifyjs issue... will investigate this further – rob Nov 11 '14 at 15:49