-
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
Visiting a cross origin page with a cy.origin
command with no cy commands may cause subsequent tests to hang.
#21300
Comments
I think the workaround doesn't work all the time since I've regularly come across hanging tests in the experimentalSessionAndOrigin job on CircleCI. Running list of examples in CircleCI, will update as I come across them:
|
This will be fixed by #23297 |
The code for this is done in cypress-io/cypress#23297, 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
Since we no longer wait for stability before ending a test test we may now end up in a race condition where an unload event initiated in a previous test will occur in a subsequent test, setting stability to false. If that load event happens for a cross origin page the test will hang, forever since stability won't be set back to true.
It was assumed that setting the iframes src to the
about:blank
page would cancel any current load events happening within the iframe, but the opposite appears to be true, if the iframe is currently loadingDesired behavior
The second test should not hang based on commands run in the first test.
I believe we have to options to fix this, one more extreme than the other.
Wait for stability prior to loading the about blank page in sessions/index. To achieve stability here, we will have know which spec bridge to continue to listen too and persist that state between tests. Currently this is handled within tests by the
latestActiveOriginPolicy
state, but that is cleared between tests. See relevant event-manager linesRevert the change that allows us to proceed in the event manager regardless of stability and instead allow
cy.visit
to successfully load cross-origin pages. This requires more investigation, but would have the dual effects of making it less confusing to visit pages (you could visit a cross origin page prior to entering a cy.origin block and allow us to remove code around syncing stability as you could not exit the command queue without being stable. Any any commands run after a visit would have to run against the correct origin. The downside of this approach would be that again, we'd be waiting on stability before exiting mocha blocks (but we've seen what not waiting can do) and we'd have to error incy.visit
s on load functions if someone attempts to run them against a cross origin url. On loads would also have to be setup prior to visiting.Test code to reproduce
The following test can be used to reproduce this issue in the 'driver' package of the cypress repo. This is most easily reproduced on firefox, but has also been observed on chrome.
Cypress Version
9.6.0
Other
No response
The text was updated successfully, but these errors were encountered: