cypress: Problem cancelling XHRs from previous test
Current behavior:
Yep, there is an issue if you don’t wait for all XHRs to finish after a test. When it tries to cancel the XHR it fails with the error: -
UnsubscriptionError: 1 errors occurred during unsubscription:
1) TypeError: Cannot set property 'aborted' of undefined
if I do an explicit cy.wait(2000) or cy.wait('@myxhr') it works
note it’s the following test that fails, not the one with the XHR
Desired behavior:
The XHR should be cancelled correctly before the next test starts
How to reproduce:
Have a longish running XHR fire at the end of one test and have a subsequent test.
Additional Info (images, stack traces, etc)
It seems to happen when I am faking a route failure (status 500) and then make another (non-faked) XHR (to report the error to a server). e.g.: -
cy.route({
method: 'PUT',
url: '/Endpoint/Id',
status: 500,
response: ''
}).as('saveStuff');
- Operating System: Ubuntu 16.04
- Cypress Version: 1.0.2
- Browser Version: Electron 53
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 9
- Comments: 62 (11 by maintainers)
Commits related to this issue
- fix issues around aborted xhrs (#2969) - fixes #761 - fixes #1652 - fixes #2968 — committed to cypress-io/cypress by brian-mann 6 years ago
@brian-mann I still have the problem in 1.0.3 (Chrome 62, Electron 53 in both)
Just to confirm, we’re not using
this.retries()in our tests and still seeing this, but that’s worth checking for others.I’m facing the same problem with cypress 1.4.1.
Released in
3.1.4.@jennifer-shehane How is the status of this, now having a reproducible example?
@bahmutov @jennifer-shehane … I created a simple public reproduction demo:
Tested page: https://mlc-demo-cypress.firebaseapp.com (Stackblitz source: https://stackblitz.com/edit/mlc-angular-demo-cypress) Testing code:
The result of the test looks:
And the error like:

We’re facing the same problem with 3.1.0.
Sadly @StormPooper’s hack doesn’t seem to work for us.
We’re doing this (based on https://github.com/cypress-io/cypress/issues/761#issuecomment-352375786) in our
support/index.js:Had to catch it in
failtoo since it doesn’t seem to treat it as an uncaught exception from your own tests. It’s still not great as it means if something fails for the same reason it’ll assume everything’s fine, but we’ve found it better than loading another page after each test.I’m getting these errors when calling visit on a new url after running over from one test spec file to the next.
Currently having to do something nasty like:
@StormPooper - thanks for that suggestion. Unfortunately, commenting out either doesn’t work. Only using it on
uncaught:exceptionresults in the originalcannot set 'aborted'failure, and only using it onfailresults in all subsequent tests immediately passing and never running.Hopefully Cypress is able to handle this scenario properly soon. It’s pretty much the only thing standing in the way of migrating from TestCafe to Cypress.
Still an issue with 3.0.1 too.
@rafaelchiti did you have any success with the PubNub long polling and Cypress? Some of the functionality i want to test is dependent on it so I don’t really want to stub it out.
@brian-mann If you no longer abort XHRs between tests how come we all still get this error ? I’m using 2.1.0 and I keep having this problem. Thanks
Hi, I’m using rxjs and redux-obsevables in my app. There was no problem in Cypress 3.1.2 with aborting requests by
takeUntiloperator from rxjs. But after upgrade to 3.1.4 I sometimes have an error like:Error: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'json').I think it’s caused by solving this 🐛
@jennifer-shehane We are able to reproduce against a website. We do not want to publicly share the website URL — if you are interested, we can send the website URL via mail and post the tests here a dot menk at imi dot de is mail mail
I am also experiencing this with 1.4.2. I am not making any requests or even repeating
cy.visitat the beginning of each test. I also don’t see any aborted XHRs in the Cypress sidebar or failed requests in the Chome Dev Tools.