You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a 3rd party lib such as new relic's js instrumentation library wraps XHR's the same way Cypress does, it's possible for there to be an infinite loop while we both call the backed up XHR methods.
I've paired down the root cause to this snippet of code which can cause it.
varhandlers=["onload","onerror","onreadystatechange"]varwrapXhr=function(){varxhr=thishandlers.forEach(function(handler){varbak=xhr[handler]xhr[handler]=function(){if(typeofbak==="function"){bak.apply(xhr,arguments)}}})}varxhr=newXMLHttpRequestxhr.addEventListener("readystatechange",wrapXhr,false)xhr.open("GET","/comments.json")xhr.onload=function(){// this should continue to hitdebugger}xhr.send()
The text was updated successfully, but these errors were encountered:
brian-mann
changed the title
Infinite recursion 3rd party libs are instrumenting XHR's
Infinite recursion when 3rd party libs are instrumenting XHR's
Jun 14, 2016
Having a similar issue in 3.3.1, when a user has the New Relic insturmentation code directly embedded in their page, New Relic will replace win.XMLHttpRequest with their own copy, which destroys the functions that we add on to the XMLHttpRequest object.
Doing something like this to rebind the XMLHttpRequest makes the tests pass roughly 50% of the time:
functionstubXHR($win){Cypress.state('server').bindTo($win)}it('loads the page',()=>{cy.server();cy.visit('https://'+server,{onBeforeLoad: stubXHR});});
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
If a 3rd party lib such as new relic's js instrumentation library wraps XHR's the same way Cypress does, it's possible for there to be an infinite loop while we both call the backed up XHR methods.
I've paired down the root cause to this snippet of code which can cause it.
The text was updated successfully, but these errors were encountered: