percy-cypress: Fails to POST DOM snapshot to CLI server: `TypeError: Cannot read property 'end' of undefined`

Percy snapshot seems to be failing with the following error

CypressError: cy.then()timed out after waiting15000ms`.

Your callback function returned a promise that never resolved.

The callback function was:

async () => { if (Cypress.config(‘isInteractive’) && !Cypress.config(‘enablePercyInteractiveMode’)) { return cylog(‘Disabled in interactive mode’, { details: ‘use “cypress run” instead of “cypress open”’, name }); }

// Check if Percy is enabled
if (!await utils.isPercyEnabled()) {
  return cylog('Not running', { name });
}

// Inject @percy/dom
if (!window.PercyDOM) {
  // eslint-disable-next-line no-eval
  eval(await utils.fetchPercyDOM());
}

// Serialize and capture the DOM
return cy.document({ log: false }).then(dom => {
  let domSnapshot = window.PercyDOM.serialize({ ...options, dom });

  // Post the DOM snapshot to Percy
  return utils.postSnapshot({
    ...options,
    environmentInfo: ENV_INFO,
    clientInfo: CLIENT_INFO,
    domSnapshot,
    url: dom.URL,
    name
  }).then(() => {
    // Log the snapshot name on success
    cylog(name, { name });
  }).catch(error => {
    // Handle errors
    log.error(`Could not take DOM snapshot "${name}"`);
    log.error(error);
  });
});

}

https://on.cypress.io/then`

Code: cy.visit('/') cy.url().should('include', '/auth/signup') cy.percySnapshot()

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 26 (10 by maintainers)

Most upvoted comments

On different CircleCI tab I see the same error coming from Cypress from all failing tests including that one about Error: The name of each snapshot must be unique, and this name already exists in the build

CypressError: `cy.then()` timed out after waiting `4000ms`.

Your callback function returned a promise that never resolved.

The callback function was:

dom => {
      let domSnapshot = window.PercyDOM.serialize({ ...options, dom });

      // Post the DOM snapshot to Percy
      return utils.postSnapshot({
        ...options,
        environmentInfo: ENV_INFO,
        clientInfo: CLIENT_INFO,
        domSnapshot,
        url: dom.URL,
        name
      }).then(() => {
        // Log the snapshot name on success
        cylog(name, { name });
      }).catch(error => {
        // Handle errors
        log.error(`Could not take DOM snapshot "${name}"`);
        log.error(error);
      });
    }

https://on.cypress.io/then
    at http://localhost:3000/__cypress/runner/cypress_runner.js:155144:24
    at tryCatcher (http://localhost:3000/__cypress/runner/cypress_runner.js:10325:23)
    at http://localhost:3000/__cypress/runner/cypress_runner.js:5447:41
    at tryCatcher (http://localhost:3000/__cypress/runner/cypress_runner.js:10325:23)
    at Promise._settlePromiseFromHandler (http://localhost:3000/__cypress/runner/cypress_runner.js:8260:31)
    at Promise._settlePromise (http://localhost:3000/__cypress/runner/cypress_runner.js:8317:18)
    at Promise._settlePromise0 (http://localhost:3000/__cypress/runner/cypress_runner.js:8362:10)
    at Promise._settlePromises (http://localhost:3000/__cypress/runner/cypress_runner.js:8438:18)
    at _drainQueueStep (http://localhost:3000/__cypress/runner/cypress_runner.js:5032:12)
    at _drainQueue (http://localhost:3000/__cypress/runner/cypress_runner.js:5025:9)
    at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:3000/__cypress/runner/cypress_runner.js:5041:5)
    at Async.drainQueues (http://localhost:3000/__cypress/runner/cypress_runner.js:4911:14)
From Your Spec Code:
    at Context.eval (http://localhost:3000/__cypress/tests?p=cypress/support/index.js:6312:40)

On running with --verbose I could see the following extra logs apart from the ones posted above

(node:13894) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'end' of undefined at IncomingMessage.request.on (*/testFilePath/node_modules/@percy/core/dist/server.js:88:69) at processTicksAndRejections (internal/process/next_tick.js:81:5) (node:13894) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:13894) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.