Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selenium Error When Raven is Initialized #495

Closed
bluecollarcoder opened this issue Feb 3, 2016 · 20 comments
Closed

Selenium Error When Raven is Initialized #495

bluecollarcoder opened this issue Feb 3, 2016 · 20 comments

Comments

@bluecollarcoder
Copy link

All my Selenium tests pass before I integrated Raven. Tests still pass if I load the Raven JS file but not initialize Raven. Tests fail in Firefox ONLY with:

Error: [frame("even-iframe-embed1")] Error response status: 13, UnknownError - An unknown server-side error occurred while processing the command. Selenium error: Permission denied to access property "__raven__"

if Raven is loaded and initialized. Here is the initialization code:

window.Raven.config('<%=loggerKey%>', {
  release: '<%=version%>'
}).install();

Any help with this issue will be appreciated.

@darkkn8t
Copy link

darkkn8t commented Feb 3, 2016

+1 Facing the same issue when running on Firefox using Selenium

@benvinegar
Copy link
Contributor

Is there any possibility of either of you putting together a repository with a reproducible example?

Questions I'd have:

  • Does the error occur when install() is called? Or later during test execution?
  • Does the error occur on a particular type of event, e.g. an event listener or XHR handler?

@bluecollarcoder
Copy link
Author

Error seems to happen during install(). If I remove that call, tests work; if I add it back in, tests fail. I ran across this problem on an internal project. I will try to put together an example.

@srshah19 If you have something that you could share, I would appreciate it.

@darkkn8t
Copy link

darkkn8t commented Feb 4, 2016

Unfortunately I will not be able to share the repo. But I can try and explain what is happening:

Our app is a Django Project.

  1. Using Raven JS directly from the CDN in the base template.
  2. Calling the Raven.captureException(error); on a function().then().catch() block.

Selenium tests only fail when using Firefox. Here is the exception: Unexpected Exception: Error: Permission denied to access property "__raven__".
Does this help?

@bluecollarcoder
Copy link
Author

After some more digging, it seems that the problem is caused by line 249:

// We don't wanna wrap it twice!
if (func.__raven__) {
    return func;
}

A console log right before this line shows that func is a native function (in this case it is the window.addEventListener function). So it would seem that a combination of WebDriver and FF throws exceptions when trying to modify a native function. Adding a try..catch before this line to handle the error case fixes the problem:

try {
  func.__raven__;
} catch (e) {
  return func;
}

@benvinegar However, I am not certain that this is the right long-term fix. Please advise.

@bluecollarcoder
Copy link
Author

Also for completeness, I should mention that the caller function that is triggering this exception is line 683:

return orig.call(this, evt, self.wrap(fn), capture, secure);

in the function _wrapBuiltIns. Removing self.wrap() or moving it into the try block also fixes the problem.

@benvinegar
Copy link
Contributor

We should probably do what you've done, which is try/catch the __raven__ access.

I notice that the folks at Bugsnag put try/catch around their entire wrap function. Looks like it was to solve the same problem.

So I'm in favor of going ahead with that solution. I can put a fix together w/ a test shortly and cut it w/ the same release. Or if you're so inclined, I'll accept a PR too :)

@bluecollarcoder
Copy link
Author

@benvinegar I don't quite understand the reasoning and logic behind wrapping addEventListener and removeEventListener. It's going to take me some time to grok it and put in a fix. I can certainly do it, but might take a little while.

@benvinegar
Copy link
Contributor

@bluecollarcoder – to be clear, I prefer the solution of putting the try/catch in Raven.wrap when accessing the __raven__ property.

@bluecollarcoder
Copy link
Author

In that case, I will work on it later this week.

Just so I understand the fix, what is the correct behavior if func is a native function (thus throwing the exception)? Should it be returned as is (like in my workaround), or should it be wrapped anyway (like in the original logic)?

If the correct behavior is to wrap it, then we would still need to mark a function as wrapped without causing the permission exception. Maybe instead of attaching a flag to the function itself, we would need to use a collection that holds the wrapped functions.

Let me know your thoughts.

@bluecollarcoder
Copy link
Author

@benvinegar Ha. Just saw that you posted a blog post about function wrapping. Very timely, thanks.

@dimeloper
Copy link

What's the status with this issue? Will it be fixed in an upcoming release?

@benvinegar
Copy link
Contributor

@dkiriakakis I'll get a fix together today and we'll cut a release ASAP.

@darkkn8t
Copy link

darkkn8t commented Feb 8, 2016

Thanks @benvinegar !

benvinegar added a commit that referenced this issue Feb 9, 2016
Fix Raven.js throwing exception when run in Selenium (fixes #495)
@browniefed
Copy link

Running an older version of Selenium and running into Permission denied to access property '__raven_wrapper__'

It appears to be this error that is cropping up. I'm running latest 2.1.1, importing via commonjs (webpack) and calling install.

EDIT: This was meant for people googling. This was caused by an older firefox, and after upgrading firefox and selenium this no longer happens.

scothis added a commit to scothis/raven-js that referenced this issue Sep 2, 2016
Accessing the `__raven_wrapper__` property in Firefox 48 when run under
Selenium results in the following error:

    Uncaught WebDriverError: Permission denied to access property "__raven_wrapper__" (WARNING: The server did not provide any stacktrace information)
        Command duration or timeout: 10 milliseconds
    Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700'
    System info: host: '199-7-164-50', ip: '199.7.164.50', os.name: 'windows', os.arch: 'x86', os.version: '6.2', java.version: '1.8.0_91'
    Driver info: org.openqa.selenium.firefox.FirefoxDriver
    Capabilities [{browserstack.localIdentifier=travis-3840.1, raisesAccessibilityExceptions=false, browserstack.tunnelIdentifier=travis-3840.1, browserstack.selenium.jar.version=3.0.0-beta2, appBuildId=20160726073904, platform=XP, specificationLevel=0, acceptSslCerts=false, browserstack.key=GpeJcf7DBqk3pHnB3PkZ, browser=firefox, browserVersion=48.0, platformVersion=6.2, acceptSslCert=false, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=Firefox, takesScreenshot=true, browser_version=48.0, platformName=Windows_NT, 64bit=true, browserstack.debug=false, rotatable=false, browserstack.ie.noFlash=false, browserstack.user=dhcole, version=48.0, proxy={}, command_id=1, firefox_binary=c:\Program Files (x86)\firefox 48.0\firefox.exe, browserstack.video=true, orig_os=win8, takesElementScreenshot=true, device=desktop, proxy_type=privoxy}]
    Session ID: 8ad81e9d-f345-48a9-b1fe-def338169a10
        at WebDriverError (node_modules/selenium-webdriver/lib/error.js:27:10)
        at Object.checkLegacyResponse (node_modules/selenium-webdriver/lib/error.js:639:15)
        at parseHttpResponse (node_modules/selenium-webdriver/http/index.js:538:13)
        at node_modules/selenium-webdriver/http/index.js:472:11
        at ManagedPromise.invokeCallback_ (node_modules/selenium-webdriver/lib/promise.js:1379:14)
        at TaskQueue.execute_ (node_modules/selenium-webdriver/lib/promise.js:2913:14)
        at TaskQueue.executeNext_ (node_modules/selenium-webdriver/lib/promise.js:2896:21)
        at node_modules/selenium-webdriver/lib/promise.js:2820:25
        at node_modules/selenium-webdriver/lib/promise.js:639:7
    From: Task: WebDriver.executeScript()
        at WebDriver.schedule (node_modules/selenium-webdriver/lib/webdriver.js:377:17)
        at WebDriver.executeScript (node_modules/selenium-webdriver/lib/webdriver.js:526:16)
        at WebDriver.driver.load (test/suites/selenium/_init.js:180:14)
        at test/suites/selenium/_init.js:100:14
        at initDriver (test/suites/selenium/_init.js:192:5)
        at test/suites/selenium/_init.js:147:9
        at node_modules/browserstack-local/lib/Local.js:46:11
        at ChildProcess.exithandler (child_process.js:204:7)
        at maybeClose (internal/child_process.js:829:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

By wrapping the access, we can avoid the error.

Relates to getsentry#495
scothis added a commit to scothis/raven-js that referenced this issue Sep 2, 2016
Accessing the `__raven_wrapper__` property in Firefox 48 when run under
Selenium results in the following error:

    Uncaught WebDriverError: Permission denied to access property "__raven_wrapper__" (WARNING: The server did not provide any stacktrace information)
        Command duration or timeout: 10 milliseconds
    Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700'
    System info: host: '199-7-164-50', ip: '199.7.164.50', os.name: 'windows', os.arch: 'x86', os.version: '6.2', java.version: '1.8.0_91'
    Driver info: org.openqa.selenium.firefox.FirefoxDriver
    Capabilities [{browserstack.localIdentifier=travis-3840.1, raisesAccessibilityExceptions=false, browserstack.tunnelIdentifier=travis-3840.1, browserstack.selenium.jar.version=3.0.0-beta2, appBuildId=20160726073904, platform=XP, specificationLevel=0, acceptSslCerts=false, browserstack.key=GpeJcf7DBqk3pHnB3PkZ, browser=firefox, browserVersion=48.0, platformVersion=6.2, acceptSslCert=false, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=Firefox, takesScreenshot=true, browser_version=48.0, platformName=Windows_NT, 64bit=true, browserstack.debug=false, rotatable=false, browserstack.ie.noFlash=false, browserstack.user=dhcole, version=48.0, proxy={}, command_id=1, firefox_binary=c:\Program Files (x86)\firefox 48.0\firefox.exe, browserstack.video=true, orig_os=win8, takesElementScreenshot=true, device=desktop, proxy_type=privoxy}]
    Session ID: 8ad81e9d-f345-48a9-b1fe-def338169a10
        at WebDriverError (node_modules/selenium-webdriver/lib/error.js:27:10)
        at Object.checkLegacyResponse (node_modules/selenium-webdriver/lib/error.js:639:15)
        at parseHttpResponse (node_modules/selenium-webdriver/http/index.js:538:13)
        at node_modules/selenium-webdriver/http/index.js:472:11
        at ManagedPromise.invokeCallback_ (node_modules/selenium-webdriver/lib/promise.js:1379:14)
        at TaskQueue.execute_ (node_modules/selenium-webdriver/lib/promise.js:2913:14)
        at TaskQueue.executeNext_ (node_modules/selenium-webdriver/lib/promise.js:2896:21)
        at node_modules/selenium-webdriver/lib/promise.js:2820:25
        at node_modules/selenium-webdriver/lib/promise.js:639:7
    From: Task: WebDriver.executeScript()
        at WebDriver.schedule (node_modules/selenium-webdriver/lib/webdriver.js:377:17)
        at WebDriver.executeScript (node_modules/selenium-webdriver/lib/webdriver.js:526:16)
        at WebDriver.driver.load (test/suites/selenium/_init.js:180:14)
        at test/suites/selenium/_init.js:100:14
        at initDriver (test/suites/selenium/_init.js:192:5)
        at test/suites/selenium/_init.js:147:9
        at node_modules/browserstack-local/lib/Local.js:46:11
        at ChildProcess.exithandler (child_process.js:204:7)
        at maybeClose (internal/child_process.js:829:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

By wrapping the access, we can avoid the error.

Relates to getsentry#495
scothis added a commit to scothis/raven-js that referenced this issue Sep 2, 2016
Accessing the `__raven_wrapper__` property in Firefox 48 when run under
Selenium results in the following error:

    Uncaught WebDriverError: Permission denied to access property "__raven_wrapper__" (WARNING: The server did not provide any stacktrace information)
        Command duration or timeout: 10 milliseconds
    Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700'
    System info: host: '199-7-164-50', ip: '199.7.164.50', os.name: 'windows', os.arch: 'x86', os.version: '6.2', java.version: '1.8.0_91'
    Driver info: org.openqa.selenium.firefox.FirefoxDriver
    Capabilities [{browserstack.localIdentifier=travis-3840.1, raisesAccessibilityExceptions=false, browserstack.tunnelIdentifier=travis-3840.1, browserstack.selenium.jar.version=3.0.0-beta2, appBuildId=20160726073904, platform=XP, specificationLevel=0, acceptSslCerts=false, browserstack.key=GpeJcf7DBqk3pHnB3PkZ, browser=firefox, browserVersion=48.0, platformVersion=6.2, acceptSslCert=false, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=Firefox, takesScreenshot=true, browser_version=48.0, platformName=Windows_NT, 64bit=true, browserstack.debug=false, rotatable=false, browserstack.ie.noFlash=false, browserstack.user=dhcole, version=48.0, proxy={}, command_id=1, firefox_binary=c:\Program Files (x86)\firefox 48.0\firefox.exe, browserstack.video=true, orig_os=win8, takesElementScreenshot=true, device=desktop, proxy_type=privoxy}]
    Session ID: 8ad81e9d-f345-48a9-b1fe-def338169a10
        at WebDriverError (node_modules/selenium-webdriver/lib/error.js:27:10)
        at Object.checkLegacyResponse (node_modules/selenium-webdriver/lib/error.js:639:15)
        at parseHttpResponse (node_modules/selenium-webdriver/http/index.js:538:13)
        at node_modules/selenium-webdriver/http/index.js:472:11
        at ManagedPromise.invokeCallback_ (node_modules/selenium-webdriver/lib/promise.js:1379:14)
        at TaskQueue.execute_ (node_modules/selenium-webdriver/lib/promise.js:2913:14)
        at TaskQueue.executeNext_ (node_modules/selenium-webdriver/lib/promise.js:2896:21)
        at node_modules/selenium-webdriver/lib/promise.js:2820:25
        at node_modules/selenium-webdriver/lib/promise.js:639:7
    From: Task: WebDriver.executeScript()
        at WebDriver.schedule (node_modules/selenium-webdriver/lib/webdriver.js:377:17)
        at WebDriver.executeScript (node_modules/selenium-webdriver/lib/webdriver.js:526:16)
        at WebDriver.driver.load (test/suites/selenium/_init.js:180:14)
        at test/suites/selenium/_init.js:100:14
        at initDriver (test/suites/selenium/_init.js:192:5)
        at test/suites/selenium/_init.js:147:9
        at node_modules/browserstack-local/lib/Local.js:46:11
        at ChildProcess.exithandler (child_process.js:204:7)
        at maybeClose (internal/child_process.js:829:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

By wrapping the access, we can avoid the error.

Relates to getsentry#495
@Githraine
Copy link

This just popped up for us today. Is anyone else seeing this issue?

@vladikoff
Copy link

@Githraine Are you using the latest version of Raven?

@vladikoff
Copy link

@Githraine you need this fix in ~2-3 places in raven: scothis@152598a

@Githraine
Copy link

Githraine commented Jun 6, 2017

@vladikoff
It literally just started failing today. If Raven updated then it did so silently.
EDIT:
it does look like FF updated today.
We never made changes to Raven before and had no issues...

using cucumber (2.4.0)
FF 53
Thanks

@rsleggett
Copy link

I also have this issue with webdriver-manager and firefox 53.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants