StackTrace-GPS looking for nonexistent file when error is inside a bundled JS file

261 views Asked by At

I'm trying to use StackTrace and StackTraceGPS to extract code error locations, however, when an error occurs inside a a bundled file, it tries to retrieve a non-existent file.

For example my vendors.min.js is just a combined and minifed file of jQuery, jQueryUi.

In my app I load

vendors.min.js

app.min.js

Then I trigger an error inside app.min.js and get this error object:

Uncaught TypeError: (intermediate value).run is not a function
    at HTMLDocument.<anonymous> (app.js:95)
    at HTMLDocument.dispatch (vendors.min.js?v=6.0.83-11025:formatted:2393)
    at HTMLDocument.m.handle (vendors.min.js?v=6.0.83-11025:formatted:2325)

Now when I send this stack to

StackTrace.fromError(error).then(stackTraceCallback);
function stackTraceCallback(stackFrames) {
  const gps = new StackTraceGPS();
  const newFrames = new Array(stackFrames.length)
  let frameResolved = 0;

  function allFramesResolved(){

    const newFrameStrings = newFrames.map(function(frame) {
      return frame.toString();
    })
    console.log('allFramesResolved has completed');
    console.log(newFrameStrings.join("\n"))
  }

  stackFrames.forEach((stackFrame, i) => {
    gps.pinpoint(stackFrame)
    .then(function(newFrame: any) {
      newFrames[i] = newFrame
      frameResolved++;
      if (frameResolved === stackFrames.length) {
        allFramesResolved()
      }
    }, function(){
      console.error(arguments);
    });
  });
}

Printing the stackFrame I would get this:

{columnNumber:0,
fileName:"http://example.com/dist/jquery-3.1.0.js",
functionName:"handle",
lineNumber:4918}

It's trying to load jquery-3.1.0.js which does not exist and is never loaded. All of jQuery resides inside of my vendors.min.js. All files that I use have source-mappings and my minified app.js file shows the location of the error just fine, so that works.

0

There are 0 answers