-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Cypress getting into an infinite XHR request loop #1068
Cypress getting into an infinite XHR request loop #1068
Comments
That's a very interesting bug!
|
I've yet to figure out exactly what the cause here is. The particular XHR code is a Is there a way from the Cypress GUI to get to the developer console for the page I'm testing to see if there's any useful information in the console / network tab? |
Are you using React 16? I have seen this happen in my React app when running in Cypress when there was an error that was not being handled properly by an ErrorBoundary component. I kind of assumed this was reflective of the behavior of my application though and didn't look at the live application in the circumstance. I fixed my ErrorBoundary problem and it hasn't happened since. I could recreate that circumstance if you think there's any chance this sounds related. 🤔 |
@jackfranklin just open your Dev Tools. Everything is in there the same as when you use your application outside of Cypress. |
@brian-mann that's what I thought; but when I open the dev tools they don't work. I'm assuming this is because the browser is locked in an infinite loop of some sorts. @jennifer-shehane that sounds relevant, I'll do some digging into that. I'll see if I can fix it by using an error boundary to catch any problems. |
We are currently using React 15 and also have this problem. Will an update to React 16 solve this problem as @jennifer-shehane indicates? |
This is not possible to track down without a reproducible repo. Cypress works with XHR mocking on a large number of projects including many many react 15 and react 16 projects. |
We really need a small reproducible example to begin work on this issue. |
I have just installed cypress via npm. With just the default settings I get into an infinite loop of GET requests after redirecting to the url below. The requests in browser's console are just like on @lsplogi screenshot. I'm on Debian 9, using Chrome Version 65.0.3325.146 (Official Build) (64-bit). My code: describe('Cypress infinite loop', function() {
it('hangs', function(){
cy.visit('https://evryplace.com/panel');
})
}) Output:
|
Yep, this code does cause this never loading behavior. Thanks @balmar. The behavior looks oddly similar to this other issue's test code I just ran here: #1235 (comment) it('hangs', function () {
cy.visit('https://evryplace.com/panel/')
}) |
This was my "welcome to Cypress" bug. I went through the tutorial on my project, and then it got stuck in this XHR loop. I can choose any route too and I get the same response. In this video recording, I chose a bad route. It didn't matter -- XHR loop. Only changing from Canary to Chrome solved it. (See screen cast below) |
This comment has been minimized.
This comment has been minimized.
In my case I was migrating tests from nightmare where you need to fire the callback when the test is complete. I had left the callback in the function call. Was: it('should test something', (done) => { ... }) Now: it('should test something', () => { ... }) Tests no longer hang - this wont be a fix for the majority but thought I would add it for others to check. |
@jennifer-shehane , i am also facing same xhr waiting scenario any update or alternative code snippets to place in config files like (commands file or cypress.json) wherein we would put timeout for xhr to complete and if there are uable to complete within provided timeframe we could cancel the request and continue with other test cases for time being till we could resolve this bug. |
I see it's been almost a year since this thread was last addressed: any updates on this? Works fine when using Electron but hangs forever in Chrome. I'm trying to decide between using Cypress or something else like WebDriverIO combined with Jest for the React module testing. This is a big red flag right out of the gate, along with a community that doesn't keep up. |
I am facing this same issue with infinite xhr loop when using wait.. any workaround would be appreciated |
This comment has been minimized.
This comment has been minimized.
I also have this issue. The xhr request will get stuck in an infinite loop when I run Cypress through the GUI. When I run cypress headless it works perfectly fine. The GUI will freeze and I will have to force close it through the activity monitor. It is a web component using React. |
I'm experiencing the same - it doesn't always reproduce, but is much more likely to do so when hitting a slower environment. |
I also have this issue. The XHR request will get stuck in an endless loop. Any progress for fixing this? |
I just ran into this issue after trying to fix The culprit was the addition of: Cypress.on('window:before:load', win => {
delete win.fetch;
}); Removing the above fixed my issues. |
This is still happening, no updates after 3 years with this issue opened. Problem still happens only in GUI mode. |
I've had the same issue described here, but it's only consistently failing when running But I noticed it doesn't happen when using Firefox, so I've switched CI to use Firefox and so far it's ok. I really was hoping to test the frontend on Chrome though, so I'm looking forward for a solution. |
@swiecaJS That's actually a separate issue here. The Office login page has some code that detects if it's running in an iframe, and if so reload itself / make some requests. Cypress works by running everything within an iframe, so that's where this becomes a problem. However, our new system of source rewriting is designed to fix some issues like this, which you can enable by setting As far as the original issue goes, I've been able to narrow down the issue and am trying to figure out a viable fix. |
As for the original reported bug, it looks like the underlying issue was actually #7187, which has to do with how our snapshot functionality would accidentally interact with documents using custom elements. A PR #8080 has been created to address this, and fixes the issue initially reported here with |
The code for this is done in cypress-io/cypress#8080, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior:
When visiting a page on our site through Cypress we're seeing it never complete loading because something causes the XHR requests being made to be made infinitely.
If we look at the Cypress CLI output when running the test we see:
This request is only made by our application once; if I got to the page in a browser and watch the network tab I can see that the request is made once. Watching the test through the Cypress UI, I can see that the browser just hangs and becomes unresponsive as all these requests are firing.
I'm not sure what, but something is causing these requests to run again and again and again.
Interestingly, this only happens via
cypress open
and then running the test through the UI. If I docypress run
and watch the video, the test does complete and the XHR requests complete as expected.I'm not sure what extra info is useful here but let me know what I can provide to help with this.
The text was updated successfully, but these errors were encountered: