sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Firefox throws a TypeError if user code tries to walk up the call stack of a wrapped function

Open mhenr18 opened this issue 9 years ago • 3 comments

Do you want to request a feature or report a bug?

A bug.

What is the current behavior?

I'm using Firefox 51 (UA: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0) and working on adding Sentry into the JavaScript code for an old ASP.NET WebForms codebase, with Raven version 3.15.0 from https://cdn.ravenjs.com/3.15.0/raven.min.js.

Under certain circumstances when simulating an event on a button, some WebForms JS code (which we can't easily change - it's baked into the framework in the Sys$WebForms$PageRequestManager$_doPostBack function) tries to walk up the call stack using arguments.callee/caller.

If that call stack involves a function wrapped by Raven (which as far as I can tell involves many event handlers due to Raven wrapping addEventListener), Firefox throws a TypeError: access to strict mode caller function is censored because Raven itself has a 'use strict'; statement.

(Note that no other code is running in strict mode, and disabling Raven stops the issue from happening)

You can see this happening in Firefox here: https://jsfiddle.net/yuuoq9qq/

What is the expected behavior?

The exception shouldn't be thrown.

This is perhaps Firefox doing something overly zealous (as no other browsers have this issue). However, I wouldn't expect Raven itself to run in strict mode, as user code may not be running in strict mode and may try to do things that are totally fine in sloppy mode but are banned in strict mode.

mhenr18 avatar Jun 15 '17 05:06 mhenr18

hi @mhenr18 - thanks for the report - I appreciate the fiddle and was able to reproduce this right away. At first glance it seems like the solution here is pretty clear- raven shouldn't run in strict mode - I'll make a patch and discuss with @benvinegar if there are any other consequences I'm not considering.

MaxBittker avatar Jun 16 '17 18:06 MaxBittker

i got a kick out of that ASP.NET code sample 😛 .

MaxBittker avatar Jun 16 '17 18:06 MaxBittker

+1 We are also experiencing this exact same issue for our baked-in ASP _doPostBacks. I am not seeing any other smooth solution around this.

mattkgross avatar Aug 16 '17 17:08 mattkgross