Skip to content

cy.session failure that didn't come from my code #29496

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

Closed
crfrolik opened this issue May 9, 2024 · 9 comments · Fixed by #31788
Closed

cy.session failure that didn't come from my code #29496

crfrolik opened this issue May 9, 2024 · 9 comments · Fixed by #31788
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: session Issues when using session command type: bug

Comments

@crfrolik
Copy link

crfrolik commented May 9, 2024

Current behavior

I got this failure once. Unfortunately it did not fail the second time, so it is not easily repeatable.

As far as I can tell, the failure came from within cypress, and not from my code.

2024-05-09 12:06:40      1 failing
2024-05-09 12:06:40    
2024-05-09 12:06:40      1) cloud deployment smoke tests
2024-05-09 12:06:40           should successfully log in to the customer portal and select a tenant:
2024-05-09 12:06:40         CypressError: `cy.then()` timed out after waiting `10000ms`.
2024-05-09 12:06:40    
2024-05-09 12:06:40    Your callback function returned a promise that never resolved.
2024-05-09 12:06:40    
2024-05-09 12:06:40    The callback function was:
2024-05-09 12:06:40    
2024-05-09 12:06:40    async () => {
2024-05-09 12:06:40              setSessionLogStatus(_utils__WEBPACK_IMPORTED_MODULE_6__.statusMap.inProgress(_utils__WEBPACK_IMPORTED_MODULE_6__.SESSION_STEPS.restore));
2024-05-09 12:06:40              await (0,_utils__WEBPACK_IMPORTED_MODULE_6__.navigateAboutBlank)();
2024-05-09 12:06:40              await sessions.clearCurrentSessionData();
2024-05-09 12:06:40              return restoreSession(existingSession);
2024-05-09 12:06:40            }
2024-05-09 12:06:40    
2024-05-09 12:06:40    [https://on.cypress.io/then](https://on.cypress.io/then%1B[0m%1B[90m)
2024-05-09 12:06:40          at <unknown> ([...]__cypress/runner/cypress_runner.js:118823:75)
2024-05-09 12:06:40          at tryCatcher ([...]__cypress/runner/cypress_runner.js:1807:23)
2024-05-09 12:06:40          at <unknown> ([...]__cypress/runner/cypress_runner.js:4186:41)
2024-05-09 12:06:40          at tryCatcher ([...]__cypress/runner/cypress_runner.js:1807:23)
2024-05-09 12:06:40          at Promise._settlePromiseFromHandler ([...]__cypress/runner/cypress_runner.js:1519:31)
2024-05-09 12:06:40          at Promise._settlePromise ([...]__cypress/runner/cypress_runner.js:1576:18)
2024-05-09 12:06:40          at Promise._settlePromise0 ([...]__cypress/runner/cypress_runner.js:1621:10)
2024-05-09 12:06:40          at Promise._settlePromises ([...]__cypress/runner/cypress_runner.js:1697:18)
2024-05-09 12:06:40          at _drainQueueStep ([...]__cypress/runner/cypress_runner.js:2407:12)
2024-05-09 12:06:40          at _drainQueue ([...]__cypress/runner/cypress_runner.js:2400:9)
2024-05-09 12:06:40          at Async._drainQueues ([...]__cypress/runner/cypress_runner.js:2416:5)
2024-05-09 12:06:40          at Async.drainQueues ([...]__cypress/runner/cypress_runner.js:2286:14)

Desired behavior

No response

Test code to reproduce

Here is a snippet of my test:

    cy.session([email, sessionCacheId], () => {
      cy.visit(this.url);

      cy.origin(
        this.b2cSigninUrl,
        { args: { email, password }},
        // eslint-disable-next-line @typescript-eslint/no-shadow
        ({ email, password }) => {
          cy.url().should('match', new RegExp(`^${Cypress.env('b2cHostUrl')}`));

          cy.get('[id="signInName"]').clear();
          cy.get('[id="signInName"]').type(email);

          cy.get('[id="password"]').clear();
          cy.get('[id="password"]').type(password);

          cy.get('[id="next"]').click();
        });

      cy.url().should('match', new RegExp(`^${this.url}`));
      cy.url().should('not.contain', '/id/signin');

      cy.window().then((win) => {
        // ensure selected tenant is not cached in session
        win.sessionStorage.removeItem(this.tenantStorageKey);
      });
    }, {
      cacheAcrossSpecs: true
    });

Cypress Version

13.9.0

Node version

20.12.2

Operating System

Ubuntu 22.04

Debug Logs

No response

Other

No response

@jennifer-shehane
Copy link
Member

This is being thrown from this piece of code: https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/commands/sessions/index.ts#L435

I haven't seen this error before, I bet it is a timing thing.

@jennifer-shehane jennifer-shehane added topic: session Issues when using session command type: bug pkg/driver This is due to an issue in the packages/driver directory labels May 9, 2024
@crfrolik
Copy link
Author

crfrolik commented May 9, 2024

This may be similar to #25550.
However, that issue was closed, and I can't tell if there were any changes made.

@polina-anisova
Copy link

polina-anisova commented Aug 8, 2024

Experiencing the same issue:

Failure Message: cy.then() timed out after waiting 4000ms. Your callback function returned a promise that never resolved. 
The callback function was: async () => { 
setSessionLogStatus(utils__WEBPACK_IMPORTED_MODULE_6.statusMap.inProgress(step)); 
await (0,utils__WEBPACK_IMPORTED_MODULE_6.navigateAboutBlank)(); 
await sessions.clearCurrentSessionData(); 
return cy.whenStable(() => createSession(existingSession, step)); 
} https://on.cypress.io/then 

Chrome 127, Cypress 13.7.3
image

@marcovdbunt
Copy link

marcovdbunt commented Nov 12, 2024

Same issue here (cypress 13.15.1):
Your callback function returned a promise that never resolved. The callback function was: async () => { setSessionLogStatus(utils__WEBPACK_IMPORTED_MODULE_6_.statusMap.inProgress(utils__WEBPACK_IMPORTED_MODULE_6_.SESSION_STEPS.restore)); await (0,utils__WEBPACK_IMPORTED_MODULE_6_.navigateAboutBlank)(); await sessions.clearCurrentSessionData(); return restoreSession(existingSession); }

@davidmatium
Copy link

I run about 400 tests and see this happen ~1-2 times per-run on version 14.2.1. Seems like it's a timing issue but it frequently results in test flake for a larger test suite. Is it possible to get additional eyes on this as this seems to be a blocker long-term for us in guaranteeing test stability.

@davidmatium
Copy link

@jennifer-shehane Sorry to tag directly but this has become a huge disruption in my team. Just hoping for additional eyes or thoughts. I run 400+ tests for each PR and I see this failure at least 1-2 times per run. The workaround is to just re-run the tests which slows down the entire workflow. I've been trying to find programmatic workarounds on my end but not sure anything is possible since the failure is on the Cypress side. Open to trying anything.

I utilize session for all my authentication as well as cacheAcrossSpecs in order to minimize the amount of new sessions I create. This means for the large majority of these tests, they are restoring the session which appears to be where the issue occurs and likely why I see it so often with my large test suite.

Image

@davidmatium
Copy link

Upgrading to 14.3.3 has improved the issue (likely due to this fix #31634) but this is still happening in my pipeline.
The frequency of this issue seemed to happen every or every-other run.
Now the frequency has decreased to ~1/10 runs.

While this is a huge improvement, I'm wondering if there's still anything to be done to fully address this issue. Thank you.

@mschile
Copy link
Contributor

mschile commented May 16, 2025

Hi @davidmatium 👋🏼, glad to see there was some improvement and yes, we should be able to fully address the issue. I'll take a look at it again soon but I'll also probably need you to run with some DEBUG logs turned on so we can get some additional info. I'll keep you updated.

@mschile mschile self-assigned this May 20, 2025
@mschile
Copy link
Contributor

mschile commented May 21, 2025

@davidmatium, I built a pre-release version of Cypress (based off of v14.4.0) that includes some additional debug logging (they're automatically printed to the terminal). Could you try the new version and send me the debug logs. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: session Issues when using session command type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy