cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.1k stars 3.19k forks source link

[bug] The XHR server breaks code that relies on multiple readyStateChanges with the same readyState (3) #1150

Closed meDavid closed 6 years ago

meDavid commented 6 years ago

Symptoms I tried to make a Cypress test on a Firebase Firestore project, but it would take around 30sec to load the data inside the test runner, while outside the testrunner it would load instant. After some investigation I found out this was due to some kind of long-poll system they use to retrieve the data streams from the server. When I disabled the the XHR server inside the cypress_runner.js the issue was no longer observed.

The XHR server overrides the onreadystatechange listener and will only invoke the original listener if it hasn't already seen the readyState. But having the readyState 3 (loading) multiple times, each time with the additional responseText is perfectly legal and relied upon in the Firebase SDK for Firestore.

The specific line of code that needs to be removed or allow for multiple readystate 3 calls:

https://github.com/cypress-io/cypress/blob/2b2b6d99a9f1bf232d9c7396b25390913d5f2b18/packages/driver/src/cypress/server.coffee#L412

I don't have a limited example right now, but my guess is that any Firestore project will work.

tugceakin commented 6 years ago

I'm having the same issue. I thought something was wrong with my code, but it worked after I increased the timeout to 60 seconds. Outside the test runner page loads in ~1.5 seconds.

meDavid commented 6 years ago

@tugceakin could you validate if PR #1195 solves your issue?

alexbjorlig commented 6 years ago

@meDavid I am having this issue as well. Is it solved in a new version of Cypress - or where do I find this file after installing with NPM?

BirdInTheCity commented 6 years ago

I'm still seeing this in 3.1.0. Hoping to get this resolved!

spy4x commented 6 years ago

That would be great if somebody could fix it. May be @brian-mann or @chrisbreiding could allocate some time to it. I think we could even do something like BugBounty reward or something similar to speed it up (I'm new to it).

Our team can't use Cypress with Firestore because of it :(

bdiz commented 6 years ago

To reproduce, I have an example app/spec which will hit Firestore. Steps to run the app are on the bug I filed #2374.