stacktrace.js icon indicating copy to clipboard operation
stacktrace.js copied to clipboard

not working with IE11? Cannot parse given Error object

Open flyon opened this issue 7 years ago • 7 comments

In IE11 I get this error: Cannot parse given Error object

window.onerror = (message, file, line, column, errorObject) =>{
    StackTrace.fromError(errorObject).then(callback).catch(e => console.log(e));
}

the error that is triggered seems to be a security error that happens when a new WebSocket is created. SCRIPT5022: SecurityError

flyon avatar Jul 29 '16 10:07 flyon

Could you please change your implementation to

console.log(new Error("from onerror").stack);

and paste the output here? My guess is that there is a websocket URL and stacktrace.js is trying to resolve it, but I want to make sure.

One more thing: does it work in Firefox and Chrome?

eriwen avatar Jul 31 '16 20:07 eriwen

We're experiencing a similar problem.

The error only seems to be happening in IE11. Here's the error handling code

window.onerror = function(msg, file, lineNumber, colNo, error) {
  var e, error1, trace;

  if (!error) {
    error = new Error(msg);
  }

  try {
    return trace = StackTrace.fromError(error);
  } catch (error1) {
    e = error1;
    return OJ.console.warn(e);
  }
};

We set a breakpoint just before the try/catch block, to log some things out:

// linkid.js is from Google Analytics. This is what triggers the error
// ->SCRIPT438: Object doesn't support property or method 'getAttribute'
// ->linkid.js (1,1259)

console.log(error)
// -> error
// -> {
// ->    [functions]: ,
// ->    __proto__: { },
// ->    description: "Script error",
// ->    message: "Script error",
// ->    name: "Error",
// ->    Symbol()_n.sqmr50ckiyf: undefined,
// ->    Symbol()_o.sqmr50ckiyf: undefined
// -> }

error.trace
// -> undefined

console.trace(error)
// -> console.trace(error)
// -> undefined
// -> console.trace()
// ->   at eval code (eval code:1:1)
// ->   at eval code (eval code:1:927)
// ->   at OJ.global.onerror (https://docdatastage.doctorevidence.com/dist/js/bundle.js:146995:6)
// ->   at h (https://docdatastage.doctorevidence.com/dist/vendor.js:18199:998)
// ->   at a[b] (https://d3mvnvhjmkxpjz.cloudfront.net/js/11443/usersnap2-11443-en.js:4075:11)

kcrwfrd avatar Aug 25 '16 00:08 kcrwfrd

Has there been any movement or recent revelations on this error? I'm getting the same error in IE11 and a google search brought me here.

mcadelago avatar Nov 23 '16 19:11 mcadelago

same exact story here

window.onerror = function(msg, file, line, col, error) {
  StackTrace.fromError(error).then(callback).catch(errback);
}
var errback = function(err) { console.log('here '+ err.message);
console.log(new Error("from onerror").stack);
};
var callback = function(stackframes) {
    var stringifiedStack = stackframes.map(function(sf) {
      return sf.toString();
    }).join('\n');  };

Cannot parse given Error object

Google chrome!

embryologist avatar Sep 03 '17 21:09 embryologist

Using node 6.10, same issue in this particular case:

try {
    throw 5/0
    

  }catch(e){
    console.log('ERROR')
    StackTrace.fromError(e)
    .then(console.log);
    callback(null, failure({ status: false }, e.stack));
  }
(node:44158) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 24): Error: Cannot parse given Error object

Vadorequest avatar Feb 28 '18 14:02 Vadorequest

guys am still facing error.. I am getting minified stacktrace.. and i use stacktrace'js with npm import StackTrace from 'stacktrace-js' and then rest code look like this componentDidCatch(error, errorInfo) { if (this.props.logger) { console.log(${error.stack}) } } Any one help me to find the exact code for converting minified trace to non minified

midhun8454 avatar Mar 08 '19 16:03 midhun8454

Hi,

I'm not using stacktracejs "as is", just error-stack-parser, and had a "Cannot parse given Error object" issue with IE11 as well.

When an error object is created in IE it doesn't contain the necessary "stack" field at all, an Error needs to have been thrown for it to be defined in the resulting exception.

let error = new Error("getStack");
console.log(error);
if (detectIE()) { // https://stackoverflow.com/a/21712356
    try {
        throw error;
    } catch (e) {
        error = e;
    }
}
console.log(error);
const stackFrames = ErrorStackParser.parse(error); // replace by StackTrace.fromError(error) ?

Console output:

[object Error]{description: "getStack", message: "getStack", name: "Error"}
[object Error]{description: "getStack", message: "getStack", name: "Error", stack: "Error: getS..."}

This example obviously creates an "in-place" stack trace and may not answer the WebSocket error from the original post but maybe others... And since this issue is the first result when looking for "IE11 Cannot parse given Error object" on Google, I thought this behaviour could be worth mentioning.

StephaneSeyvoz avatar Jun 21 '19 15:06 StephaneSeyvoz