Skip to content
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

Fails to POST DOM snapshot to CLI server: TypeError: Cannot read property 'end' of undefined #367

Closed
shalem-pravas opened this issue Jun 25, 2021 · 26 comments

Comments

@shalem-pravas
Copy link

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()

@tgirgin23
Copy link

tgirgin23 commented Jun 25, 2021

This is also happening on our end, and has started about two days ago. We first thought that it could have been due to upgrading from 1.0.0-beta.54 to 1.0.0-beta.56, but quickly realized that reverting back to 1.0.0-beta.54 did not fix the issue.

We tried it with both Cypress 7.5.0 and 7.6.0.

Any advice?

@Robdel12
Copy link
Contributor

Thanks for the issue! The most helpful thing would be logs from the test run (--verbose). Weird to see this, I hope there isn't another networking error in Cypress (like 7.0 to 7.2 had in #325). It's either hanging on serializing the DOM or POST'ing the DOM to the local Percy server.

@tgirgin23
Copy link

I hope I am not doing anything wrong on my end, but the --verbose tag has not helped.

Command used:

percy exec --verbose -- cypress run --headless "--spec" "specFile"

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:3001/__cypress/runner/cypress_runner.js:136215:24
      at tryCatcher (http://localhost:3001/__cypress/runner/cypress_runner.js:10798:23)
      at http://localhost:3001/__cypress/runner/cypress_runner.js:5920:41
      at tryCatcher (http://localhost:3001/__cypress/runner/cypress_runner.js:10798:23)
      at Promise._settlePromiseFromHandler (http://localhost:3001/__cypress/runner/cypress_runner.js:8733:31)
      at Promise._settlePromise (http://localhost:3001/__cypress/runner/cypress_runner.js:8790:18)
      at Promise._settlePromise0 (http://localhost:3001/__cypress/runner/cypress_runner.js:8835:10)
      at Promise._settlePromises (http://localhost:3001/__cypress/runner/cypress_runner.js:8911:18)
      at _drainQueueStep (http://localhost:3001/__cypress/runner/cypress_runner.js:5505:12)
      at _drainQueue (http://localhost:3001/__cypress/runner/cypress_runner.js:5498:9)
      at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:3001/__cypress/runner/cypress_runner.js:5514:5)
      at Async.drainQueues (http://localhost:3001/__cypress/runner/cypress_runner.js:5384:14)

@shalem-pravas
Copy link
Author

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.

@kaminskypavel
Copy link

kaminskypavel commented Jun 28, 2021

yup, happening here as well.
using the latest cypress (7.6.0)


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);
  });
}

it also happens only on some of the tests
image

any updates?

@Robdel12
Copy link
Contributor

Can we get a full log output? What @shalem-pravas provided was the closest (there's a real error there), but having full logs would help figure out what is causing the error.

@Robdel12
Copy link
Contributor

Also what version of Node is everyone using? The error lines up with changes in an unsupported version of Node (we support only the current LTS, which is Node 12+ right now).

image

Cannot read property 'end' of undefined at IncomingMessage.request.on

@tgirgin23
Copy link

We are using v14.16.1 on our end

@kaminskypavel
Copy link

Can we get a full log output? What @shalem-pravas provided was the closest (there's a real error there), but having full logs would help figure out what is causing the error.

../node_modules/@percy/cypress/index.jsat line55
  53 | 
  54 |     // Serialize and capture the DOM
> 55 |     return cy.document({ log: false }).then(dom => {
     |                                      ^
  56 |       let domSnapshot = window.PercyDOM.serialize({ ...options, dom });
  57 | 
  58 |       // Post the DOM snapshot to Percy

@Robdel12
Copy link
Contributor

These are the kind of logs I'm asking for (percy exec --verbose -- ... would also be helpful). I'm able to reproduce the issue exactly on unsupported versions of Node, but not on any other versions (v14.16.1 or 11.10 +). Using our example app:

$ npm run test

> @ test  /examples/example-percy-cypress
> start-server-and-test start:server 8000 percy:cypress

1: starting server using command "npm run start:server"
and when url "http://localhost:8000" is responding with HTTP status code 200
running tests using command "npm run percy:cypress"


> @ start:server  /examples/example-percy-cypress
> serve -l 8000 .

UPDATE AVAILABLE The latest version of `serve` is 12.0.0

   ┌───────────────────────────────────────────────────┐
   │                                                   │
   │   Serving!                                        │
   │                                                   │
   │   - Local:            http://localhost:8000       │
   │   - On Your Network:  http://192.168.86.32:8000   │
   │                                                   │
   │   Copied local address to clipboard!              │
   │                                                   │
   └───────────────────────────────────────────────────┘


> @ percy:cypress  /examples/example-percy-cypress
> percy exec -- cypress run

(node:28987) ExperimentalWarning: The fs.promises API is experimental
[percy] Successfully downloaded Chromium 812851
[percy] Percy has started!
[percy] Running "cypress run"

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:    7.6.0                                                                              │
  │ Browser:    Electron 89 (headless)                                                             │
  │ Specs:      1 found (todo_spec.js)                                                             │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  todo_spec.js                                                                    (1 of 1)


  TodoMVC
2021-06-28 11:55:54.179 Cypress Helper (Renderer)[29404:116121] CoreText note: Client requested name ".AppleSymbolsFB", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2021-06-28 11:55:54.179 Cypress Helper (Renderer)[29404:116121] CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug.
(node:28987) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'end' of undefined
    at IncomingMessage.request.on ( /examples/example-percy-cypress/node_modules/@percy/core/dist/server.js:88:69)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
(node:28987) 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:28987) [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.
    1) Loads the TodoMVC app
2021-06-28 11:55:58.838 Cypress Helper (Renderer)[29404:116121] CoreText note: Client requested name ".AppleSymbolsFB", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
    ✓ With no todos, hides main section and footer (145ms)
2021-06-28 11:55:58.989 Cypress Helper (Renderer)[29404:116121] CoreText note: Client requested name ".AppleSymbolsFB", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2021-06-28 11:55:59.328 Cypress Helper (Renderer)[29404:116121] CoreText note: Client requested name ".AppleSymbolsFB", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
(node:28987) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'end' of undefined
    at IncomingMessage.request.on ( /examples/example-percy-cypress/node_modules/@percy/core/dist/server.js:88:69)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
(node:28987) 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: 2)
    2) Accepts a new todo
2021-06-28 11:56:03.945 Cypress Helper (Renderer)[29404:116121] CoreText note: Client requested name ".AppleSymbolsFB", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2021-06-28 11:56:04.330 Cypress Helper (Renderer)[29404:116121] CoreText note: Client requested name ".AppleSymbolsFB", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
(node:28987) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'end' of undefined
    at IncomingMessage.request.on ( /examples/example-percy-cypress/node_modules/@percy/core/dist/server.js:88:69)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
(node:28987) 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: 3)
    3) Lets you check off a todo


  1 passing (16s)
  3 failing

  1) TodoMVC
       Loads the TodoMVC app:
     CypressError: `cy.then()` timed out after waiting `4000ms`.

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
      at http://localhost:8000/__cypress/runner/cypress_runner.js:136215:24
      at tryCatcher (http://localhost:8000/__cypress/runner/cypress_runner.js:10798:23)
      at http://localhost:8000/__cypress/runner/cypress_runner.js:5920:41
      at tryCatcher (http://localhost:8000/__cypress/runner/cypress_runner.js:10798:23)
      at Promise._settlePromiseFromHandler (http://localhost:8000/__cypress/runner/cypress_runner.js:8733:31)
      at Promise._settlePromise (http://localhost:8000/__cypress/runner/cypress_runner.js:8790:18)
      at Promise._settlePromise0 (http://localhost:8000/__cypress/runner/cypress_runner.js:8835:10)
      at Promise._settlePromises (http://localhost:8000/__cypress/runner/cypress_runner.js:8911:18)
      at _drainQueueStep (http://localhost:8000/__cypress/runner/cypress_runner.js:5505:12)
      at _drainQueue (http://localhost:8000/__cypress/runner/cypress_runner.js:5498:9)
      at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:8000/__cypress/runner/cypress_runner.js:5514:5)
      at Async.drainQueues (http://localhost:8000/__cypress/runner/cypress_runner.js:5384:14)
  From Your Spec Code:
      at Context.eval (http://localhost:8000/__cypress/tests?p=cypress/support/index.js:143:6)

  2) TodoMVC
       Accepts a new todo:
     CypressError: `cy.then()` timed out after waiting `4000ms`.

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
      at http://localhost:8000/__cypress/runner/cypress_runner.js:136215:24
      at tryCatcher (http://localhost:8000/__cypress/runner/cypress_runner.js:10798:23)
      at http://localhost:8000/__cypress/runner/cypress_runner.js:5920:41
      at tryCatcher (http://localhost:8000/__cypress/runner/cypress_runner.js:10798:23)
      at Promise._settlePromiseFromHandler (http://localhost:8000/__cypress/runner/cypress_runner.js:8733:31)
      at Promise._settlePromise (http://localhost:8000/__cypress/runner/cypress_runner.js:8790:18)
      at Promise._settlePromise0 (http://localhost:8000/__cypress/runner/cypress_runner.js:8835:10)
      at Promise._settlePromises (http://localhost:8000/__cypress/runner/cypress_runner.js:8911:18)
      at _drainQueueStep (http://localhost:8000/__cypress/runner/cypress_runner.js:5505:12)
      at _drainQueue (http://localhost:8000/__cypress/runner/cypress_runner.js:5498:9)
      at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:8000/__cypress/runner/cypress_runner.js:5514:5)
      at Async.drainQueues (http://localhost:8000/__cypress/runner/cypress_runner.js:5384:14)
  From Your Spec Code:
      at Context.eval (http://localhost:8000/__cypress/tests?p=cypress/support/index.js:143:6)

  3) TodoMVC
       Lets you check off a todo:
     CypressError: `cy.then()` timed out after waiting `4000ms`.

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
      at http://localhost:8000/__cypress/runner/cypress_runner.js:136215:24
      at tryCatcher (http://localhost:8000/__cypress/runner/cypress_runner.js:10798:23)
      at http://localhost:8000/__cypress/runner/cypress_runner.js:5920:41
      at tryCatcher (http://localhost:8000/__cypress/runner/cypress_runner.js:10798:23)
      at Promise._settlePromiseFromHandler (http://localhost:8000/__cypress/runner/cypress_runner.js:8733:31)
      at Promise._settlePromise (http://localhost:8000/__cypress/runner/cypress_runner.js:8790:18)
      at Promise._settlePromise0 (http://localhost:8000/__cypress/runner/cypress_runner.js:8835:10)
      at Promise._settlePromises (http://localhost:8000/__cypress/runner/cypress_runner.js:8911:18)
      at _drainQueueStep (http://localhost:8000/__cypress/runner/cypress_runner.js:5505:12)
      at _drainQueue (http://localhost:8000/__cypress/runner/cypress_runner.js:5498:9)
      at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:8000/__cypress/runner/cypress_runner.js:5514:5)
      at Async.drainQueues (http://localhost:8000/__cypress/runner/cypress_runner.js:5384:14)
  From Your Spec Code:
      at Context.eval (http://localhost:8000/__cypress/tests?p=cypress/support/index.js:143:6)




  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        4                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      3                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  3                                                                                │
  │ Video:        false                                                                            │
  │ Duration:     15 seconds                                                                       │
  │ Spec Ran:     todo_spec.js                                                                     │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


  (Screenshots)

  -   /examples/example-percy-cypress/cypress/screens    (1920x1080)
     hots/todo_spec.js/TodoMVC -- Loads the TodoMVC app (failed).png
  -   /examples/example-percy-cypress/cypress/screens    (1920x1080)
     hots/todo_spec.js/TodoMVC -- Accepts a new todo (failed).png
  -   /examples/example-percy-cypress/cypress/screens    (1920x1080)
     hots/todo_spec.js/TodoMVC -- Lets you check off a todo (failed).png


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✖  todo_spec.js                             00:15        4        1        3        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✖  1 of 1 failed (100%)                     00:15        4        1        3        -        -

[percy] Stopping percy...
[percy] Finalized build #2950: https://percy.io/percy/rob-test-bed/builds/11200892
npm ERR! code ELIFECYCLE
npm ERR! errno 3
npm ERR! @ percy:cypress: `percy exec -- cypress run`
npm ERR! Exit status 3
npm ERR!
npm ERR! Failed at the @ percy:cypress script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/robertdeluca/.npm/_logs/2021-06-28T16_56_09_324Z-debug.log

INFO: Gracefully shutting down. Please wait...
{ Error: Command failed with exit code 3: npm run percy:cypress
    at makeError ( /examples/example-percy-cypress/node_modules/start-server-and-test/node_modules/execa/lib/error.js:59:11)
    at handlePromise ( /examples/example-percy-cypress/node_modules/start-server-and-test/node_modules/execa/index.js:114:26)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
  shortMessage: 'Command failed with exit code 3: npm run percy:cypress',
  command: 'npm run percy:cypress',
  exitCode: 3,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ test: `start-server-and-test start:server 8000 percy:cypress`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!    /.npm/_logs/2021-06-28T16_56_09_410Z-debug.log

I can only see that error (which matches what @shalem-pravas shared a snippet of) on Node 11.9.x or earlier:

$ node -v
v11.9.0

Seems to strongly suggest it's a Node version issue (or the version of node being used has been altered maybe?). A reproduction would be really helpful since I can't get it to break with that error without going down to an unsupported version of Node.

@kaminskypavel
Copy link

kaminskypavel commented Jun 28, 2021

@Robdel12 sorry I cant share the code as it's a private repo, but here's the build gist

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions/setup-node@v2
        with:
          node-version: '14'

      - name: Get yarn cache directory path
        id: yarn-cache-dir-path
        run: echo "::set-output name=dir::$(yarn cache dir)"

      - uses: actions/cache@v2
        id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
        with:
          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-

      # we use the exact restore key to avoid Cypress binary snowballing
      # https://glebbahmutov.com/blog/do-not-let-cypress-cache-snowball/
      - name: Cache Cypress binary
        uses: actions/cache@v1
        with:
          path: ~/.cache/Cypress
          key: cypress-${{ runner.os }}-cypress-${{ github.ref }}-${{ hashFiles('**/package.json') }}
          restore-keys: |
            cypress-${{ runner.os }}-cypress-${{ github.ref }}-${{ hashFiles('**/package.json') }}


      - name: Install dependencies and verify Cypress
        env:
          # make sure every Cypress install prints minimal information
          CI: 1
        run: |
          yarn install
          yarn cypress cache path
          yarn cypress cache list
          yarn cypress verify
          yarn cypress info

      - name: Cypress run
        uses: cypress-io/github-action@v2
        with:
          record: true
          build: yarn build
          start: yarn serve
          wait-on: http://localhost:3000
          command: yarn cross-env PERCY_TOKEN=${{secrets.PERCY_TOKEN_WWW}} percy exec -- cypress run --record --key ${{ secrets.CYPRESS_RECORD_KEY_WWW }}

        env:
          CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY_WWW }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

as per your request here's the node version:

      - uses: actions/setup-node@v2
        with:
          node-version: '14'

and the cypress run command

      - name: Cypress run
        uses: cypress-io/github-action@v2
        with:
          record: true
          build: yarn build
          start: yarn serve
          wait-on: http://localhost:3000
          command: yarn cross-env PERCY_TOKEN=${{secrets.PERCY_TOKEN_WWW}} percy exec -- cypress run --record --key ${{ secrets.CYPRESS_RECORD_KEY_WWW }}

@kaminskypavel
Copy link

@Robdel12 by the way, funny part is screenshots are being uploaded to percy, it's just the tests that are failing

@aleksandrlat
Copy link

Having same issue with cypress 5.6.0 and node 14.16.0
Need this to be fixed asap

@Robdel12
Copy link
Contributor

Robdel12 commented Jun 28, 2021

Need this to be fixed asap

A reproduction would be the most helpful, given I can't reproduce on Node 12+.

Using the example app with Node 14.16.1: https://github.com/percy/example-percy-cypress/runs/2934658148?check_suite_focus=true

Using the example app with Node 11.9.x fails with the error provided in this issue: https://github.com/percy/example-percy-cypress/runs/2934668779?check_suite_focus=true

The error really seems to suggest it's an issue with the version of Node being used. I can't break it in the same way (yet?) & there's only been one log posted with an error stack trace, so I'm assuming everyone is hitting this error:

(node:28987) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'end' of undefined
    at IncomingMessage.request.on ( /examples/example-percy-cypress/node_modules/@percy/core/dist/server.js:88:69)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

@Robdel12
Copy link
Contributor

Published a new version of the CLI which will hard exit if it detects a version of Node that's not supported: https://github.com/percy/cli/releases/tag/v1.0.0-beta.57

Curious if that errors or not. If not, I'm keen to get a reproduction or more details on how to reproduce this issue 👀

@aleksandrlat
Copy link

aleksandrlat commented Jun 28, 2021

This is what I have in logs in latest version v1.0.0-beta.57

@kaminskypavel
Copy link

here's my latest update

  1. node version 14.16.0
  2. "@percy/cli": "^1.0.0-beta.57"
  3. ran with verbose yarn cross-env PERCY_TOKEN=${{secrets.PERCY_TOKEN_WWW}} percy exec --verbose -- cypress run

results :

  1) /
       take a percy snapshot:
     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:136215:24
      at tryCatcher (http://localhost:3000/__cypress/runner/cypress_runner.js:10798:23)
      at http://localhost:3000/__cypress/runner/cypress_runner.js:5920:41
      at tryCatcher (http://localhost:3000/__cypress/runner/cypress_runner.js:10798:23)
      at Promise._settlePromiseFromHandler (http://localhost:3000/__cypress/runner/cypress_runner.js:8733:31)
      at Promise._settlePromise (http://localhost:3000/__cypress/runner/cypress_runner.js:8790:18)
      at Promise._settlePromise0 (http://localhost:3000/__cypress/runner/cypress_runner.js:8835:10)
      at Promise._settlePromises (http://localhost:3000/__cypress/runner/cypress_runner.js:8911:18)
      at _drainQueueStep (http://localhost:3000/__cypress/runner/cypress_runner.js:5505:12)
      at _drainQueue (http://localhost:3000/__cypress/runner/cypress_runner.js:5498:9)
      at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:3000/__cypress/runner/cypress_runner.js:5514:5)
      at Async.drainQueues (http://localhost:3000/__cypress/runner/cypress_runner.js:5384:14)
  From Your Spec Code:
      at Context.eval (http://localhost:3000/__cypress/tests?p=cypress/support/index.js:150:40)

all the test that fails has the same logs, then :

[percy] Stopping percy...
[percy] Finalized build #9: https://percy.io/f916ec5a/www.get***.com/builds/11202278
[percy] Done!
verbose 422.144894774 Error: Command failed with exit code 17.
    at ProcessTermError.ExtendableBuiltin (/usr/local/lib/node_modules/yarn/lib/cli.js:721:66)
    at ProcessTermError.MessageError (/usr/local/lib/node_modules/yarn/lib/cli.js:750:123)
    at new ProcessTermError (/usr/local/lib/node_modules/yarn/lib/cli.js:790:113)
    at /usr/local/lib/node_modules/yarn/lib/cli.js:34550:30
    at Generator.throw (<anonymous>)
    at step (/usr/local/lib/node_modules/yarn/lib/cli.js:310:30)
    at /usr/local/lib/node_modules/yarn/lib/cli.js:323:13
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
error Command failed with exit code 17.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: The process '/usr/local/bin/yarn' failed with exit code 17

I've also noticed , it always fails on the same pages.

hope this helps @Robdel12 .

@aleksandrlat
Copy link

For me the number of failed tests is different. Sometimes it varies from 31 to 35.
So my guess is something wrong with percy servers not with the code....

@Robdel12
Copy link
Contributor

Robdel12 commented Jun 28, 2021

@aleksandrlat your issue isn't at all related -- looks like you have duplicate snapshot:

[percy:core] Error: The name of each snapshot must be unique, and this name already exists in the build: 'Login page filled out - 2' -- You can fix this by passing a 'name' param when creating the snapshot. See the docs for more info on identifying snapshots for your specific client: https://percy.io/docs

if the tests are retried, that won't work with Percy (for now, in the future we'll be updating the SDKs to handle retries percy/cli#281).

@Robdel12
Copy link
Contributor

@kaminskypavel hm, that's interesting. I don't think we're talking about the same error as the original issue. I'm going to rename this one to be about the Node error (TypeError: Cannot read property 'end' of undefined).

There aren't any other logs that provide a stack trace from Percy or anything? This is pretty generic and coming from Yarn 🤔

verbose 422.144894774 Error: Command failed with exit code 17.
    at ProcessTermError.ExtendableBuiltin (/usr/local/lib/node_modules/yarn/lib/cli.js:721:66)
    at ProcessTermError.MessageError (/usr/local/lib/node_modules/yarn/lib/cli.js:750:123)
    at new ProcessTermError (/usr/local/lib/node_modules/yarn/lib/cli.js:790:113)
    at /usr/local/lib/node_modules/yarn/lib/cli.js:34550:30
    at Generator.throw (<anonymous>)
    at step (/usr/local/lib/node_modules/yarn/lib/cli.js:310:30)
    at /usr/local/lib/node_modules/yarn/lib/cli.js:323:13
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
error Command failed with exit code 17.

@Robdel12 Robdel12 changed the title Snapshot failing with "Your callback function returned a promise that never resolved" Fails to POST DOM snapshot to CLI server: TypeError: Cannot read property 'end' of undefined Jun 28, 2021
@aleksandrlat
Copy link

@Robdel12 I have more than 30 failing tests and others don't have this problem.

And these tests have been working for ages without any changes on our side

@Robdel12
Copy link
Contributor

With the logs you provided, it's because cy.percySnapshot('Login page filled out - 2') was called twice.

@aleksandrlat
Copy link

aleksandrlat commented Jun 28, 2021

Here is another test failure

Do all tests fail because of this?

But in the code cy.percySnapshot('Login page filled out - 2') is called only once.

@aleksandrlat
Copy link

aleksandrlat commented Jun 28, 2021

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)

@kaminskypavel
Copy link

kaminskypavel commented Jun 28, 2021

for everyone having this issue,

add the following line to cypress.json

{
    "projectId": "....",
    "defaultCommandTimeout": 10000   <------------ add this
}

this solves the problem. 🎉💃
@Robdel12 pretty sure its related to the cli

@Robdel12
Copy link
Contributor

Let's open another issue, the orignal issue here was addressed (#367 (comment))

These all have the same Cypress error, but any response that doesn't resolve from the CLI will have that Cypress error -- it's generic. See #371

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants