cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.

Home Page:https://cypress.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

crfrolik opened this issue · comments

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

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.

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