TraceKit
TraceKit copied to clipboard
Added try catch for .caller, breaks in safari and maybe future browsers
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
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
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:
hmm I haven't seen that, perhaps we should have a method like this:
function getCaller(curr) {
try { return curr.callee } catch(ex) {}
}
@Diophontine what's the status of this pr? Perhaps we should wrap it in a try catch as perhaps the last comment.
@Diophontine what's the status of this pr? Perhaps we should wrap it in a try catch as perhaps the last comment.
@Diophontine what's the status of this pr? Perhaps we should wrap it in a try catch as perhaps the last comment.
@Diophontine what's the status of this pr? Perhaps we should wrap it in a try catch as perhaps the last comment.
Sorry I haven't looked at the code for many years, not sure if it's still relevant