TraceKit icon indicating copy to clipboard operation
TraceKit copied to clipboard

Added try catch for .caller, breaks in safari and maybe future browsers

Open Diophontine opened this issue 7 years ago • 6 comments

Line 1075 causes issues on our Safari instance when it cannot find the caller. As a result the computeStackTraceByWalkingCallerChain function returns with no message, even if a a valid stack trace had previously existed.

Seems like .caller is also obsolete, so until the function is rewritten, it would be worth try catching the errors.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/caller https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode/Transitioning_to_strict_mode

Diophontine avatar Aug 24 '17 15:08 Diophontine

Thanks for the pr, I left a single comment. Have you come across any other strict issues? I haven't seen any myself after my last round of fixes with strict mode. Do you have the exact error that's thrown? I'd love to see the stack trace, the inner condition of the if should check to ensure caller is defined. I'm wondering if we should create a small function helper that try to get the caller of a function, which would simplify this change quite a bit and would probably be used in other places too

niemyjski avatar Aug 24 '17 16:08 niemyjski

After some further thought and discussion with others, I've removed the console.log .

The way the error itself was generated was from a Raygun call. I'm still working on reproducing from outside our setup (which involves some iframes and such) in the normal mobile safari, I'll post some more information soon.

Here is the stack trace: image

Diophontine avatar Aug 24 '17 20:08 Diophontine

hmm I haven't seen that, perhaps we should have a method like this:

function getCaller(curr) {
try { return curr.callee } catch(ex) {}
}

niemyjski avatar Aug 30 '17 21:08 niemyjski

@Diophontine what's the status of this pr? Perhaps we should wrap it in a try catch as perhaps the last comment.

niemyjski avatar Feb 23 '18 17:02 niemyjski

@Diophontine what's the status of this pr? Perhaps we should wrap it in a try catch as perhaps the last comment.

niemyjski avatar Jul 09 '18 19:07 niemyjski

@Diophontine what's the status of this pr? Perhaps we should wrap it in a try catch as perhaps the last comment.

niemyjski avatar Apr 08 '20 13:04 niemyjski

@Diophontine what's the status of this pr? Perhaps we should wrap it in a try catch as perhaps the last comment.

niemyjski avatar Sep 19 '24 14:09 niemyjski

Sorry I haven't looked at the code for many years, not sure if it's still relevant

Diophontine avatar Sep 20 '24 19:09 Diophontine