cypress-io / cypress

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

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

Open crfrolik opened 6 months ago

crfrolik commented 6 months ago

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 commented 6 months ago

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.

crfrolik commented 6 months ago

This may be similar to https://github.com/cypress-io/cypress/issues/25550. However, that issue was closed, and I can't tell if there were any changes made.

polina-anisova commented 3 months ago

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 commented 1 week ago

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