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

Cypress runner crashes after a cy.request() command times out #16476

Closed
gabi-dobritescu opened this issue May 12, 2021 · 16 comments · Fixed by #16641
Closed

Cypress runner crashes after a cy.request() command times out #16476

gabi-dobritescu opened this issue May 12, 2021 · 16 comments · Fixed by #16641
Assignees
Labels
type: bug v7.3.0 🐛 Issue present since 7.3.0

Comments

@gabi-dobritescu
Copy link

Current behaviour

The Cypress test runner crashes with a "RangeError: Maximum call stack size exceeded" error a few seconds after a cy.request() command times out.

This happens with both cypress open and cypress run.

Desired behavior

cy.request() commands that time out should not crash the test runner.

Test code to reproduce

Demo repo and instructions here: demo repo

Here's a copy of the relevant files from the project:

package.json

{
  "name": "stack-size-exceeded",
  "version": "1.0.0",
  "description": "A demo project to show the stack size exceeded error with Cypress",
  "main": "index.js",
  "author": "Gabi Dobritescu",
  "license": "MIT",
  "private": true,
  "scripts": {
    "start": "node app.js",
    "cypress:open": "node_modules\\.bin\\cypress open"
  },
  "devDependencies": {
    "cypress": "^7.3.0",
    "express": "^4.17.1"
  }
}

cypress.json

{
  "responseTimeout": 2000
}

app.js

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  setTimeout(() => {
    res.send('Hello World!')
  }, 5000)

})

app.listen(port, () => {
  console.log("Example app listening at http://localhost:${port}")
})

quick-test.spec.js

describe("Demo test for the exceed stack size error", () => {
  it("should gracefully fail the test when api request times out", () => {
    cy.request("http://localhost:3000/").then(response => {
      expect(response.body).to.equal("Hello World!");
    })
  })
})

To reproduce the issue:

yarn install

yarn start

yarn cypress:open

Run the quick-test.spec test. After the test completes (failing as expected because the request timed out before the server responded) wait for a few seconds (anywhere between 2 to 5 second usually).
The runner crashes with the following error and stacktrace:

RangeError: Maximum call stack size exceeded
    at isBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:23:18)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:46:9)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:40:17)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:40:17)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:40:17)
    ...
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:40:17)
    at Object.hasBinary (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\is-binary.js:55:63)
    at Encoder.encode (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\index.js:38:29)
    at Client._packet (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\client.js:169:44)
    at Socket.packet (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\socket.js:160:21)
    at C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\socket.js:274:18
    at C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\server\lib\socket-base.js:325:28
    at tryCatcher (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromise0 (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:649:10)
    at Promise._settlePromises (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:725:18)
    at _drainQueueStep (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:93:12)
    at _drainQueue (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\dobrites\AppData\Local\Cypress\Cache\7.3.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:15:14)
    at processImmediate (internal/timers.js:461:21)

Versions

7.3.0

@gabi-dobritescu
Copy link
Author

This is the same issue as #15629 which was recently closed. Version 7.3.0 is meant to have addressed the issue, but it's still happening for me.

@jennifer-shehane
Copy link
Member

@gabi-dobritescu This is not the same error as #15629 and is a new error, likely introduced in 7.3.0. Likely related though.

@jennifer-shehane
Copy link
Member

jennifer-shehane commented May 12, 2021

@gabi-dobritescu I actually can't recreate this from your repo on my Mac. But we have seen the same error in our test suite on our CI: https://app.circleci.com/pipelines/github/cypress-io/cypress/20432/workflows/f90d1e30-e2fe-4b80-815e-ebf2292df162/jobs/739688

Can you give any details about where you're seeing this? Is it on your CI / docker container / local OS? Also browser and browser version?

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label May 12, 2021
@Nasicus
Copy link

Nasicus commented May 12, 2021

@jennifer-shehane as mentioned on the other issue: This is not a new thing and happens since quite a few cypress versions. So I doubt it has anything to do with recent changes.

Also in our team I think only the windows users are complaining. But I can't be 100% sure on that, can try t o find out next week if required.

@jennifer-shehane
Copy link
Member

@Nasicus Can you provide a reproducible example of the issue? We're aware of other Max call stack errors in previous versions, but not with this same isBinary stack trace.

@jennifer-shehane
Copy link
Member

Our own test encountered this error in the retries.ui.spec.js on Chrome 89:

Screen Shot 2021-05-12 at 10 57 41 AM

@Nasicus
Copy link

Nasicus commented May 12, 2021

@jennifer-shehane hmm I never closely looked at it. Sorry I just assumed it was the same.
The only trace I still have is from 6.8.0 form this morning- and you're right that was indeed a different one.
Since it crashed again I just assumed it's the same error... sorry for that!

RangeError: Maximum call stack size exceeded
    at _deconstructPacket (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\binary.js:21:28)
    // ^ occurs ~15k times
    at Object.deconstructPacket (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\binary.js:16:17)
    at Encoder.encodeAsBinary (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\index.js:81:41)
    at Encoder.encode (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\socket\node_modules\socket.io-parser\dist\index.js:43:29)
    at Client._packet (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\client.js:167:44)
    at Socket.packet (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\socket.js:161:21)
    at C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\socket.js:270:18
    at C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\server\lib\socket-base.js:312:28
    at tryCatcher (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromise0 (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:649:10)
    at Promise._settlePromises (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:725:18)
    at _drainQueueStep (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:93:12)
    at _drainQueue (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\cypress.user\AppData\Local\Cypress\Cache\6.8.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

@cypress-bot cypress-bot bot added stage: backlog and removed stage: needs information Not enough info to reproduce the issue labels May 12, 2021
@jennifer-shehane jennifer-shehane added stage: needs information Not enough info to reproduce the issue and removed stage: backlog labels May 12, 2021
@jennifer-shehane
Copy link
Member

Yeah, I can recreate this in Windows 10, on Chrome 90 with this repo: https://github.com/gabi-dobritescu/exceed-stack-size/tree/master?rgh-link-date=2021-05-12T13%3A19%3A02Z

@gabi-dobritescu
Copy link
Author

@jennifer-shehane Our environments are all Win 10 and we run our test suites with the latest versions of Chrome: 89 & 90.

@jennifer-shehane jennifer-shehane added stage: backlog and removed stage: needs information Not enough info to reproduce the issue stage: backlog labels May 12, 2021
@jennifer-shehane
Copy link
Member

jennifer-shehane commented May 12, 2021

I tested this repo on Windows in Cypress 7.2.0 where I can reproduce it and it throws the deconstructPacket error from #15629.

If this boils down to the same issue as before, that was not fixed in 7.3.0, you should be able to downgrade to Cypress 6.4.0 to get around the crash.

@jennifer-shehane jennifer-shehane added the v7.3.0 🐛 Issue present since 7.3.0 label May 12, 2021
@gabi-dobritescu
Copy link
Author

gabi-dobritescu commented May 13, 2021

@jennifer-shehane Downgrading to 6.4.0 is not an option for us as we've migrated away from cy.route() to cy.intercept().

Edit: Just realised that the intercept API was first released in 6.0.0. We need a version greater than 7.0.0 as we're making use of the ability to override the stubbed response defined with intercept.

For now we're working around this issue by increasing the timeout on specific requests. Luckily we only had a few instances where we had to make changes.

@pyymenta
Copy link

Same here, I've tried to run this reproducible sample repo using the 7.3.0 version and I've got the following error:

...

    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:55:63)
    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:55:63)
    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:55:63)
    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:55:63)
    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:55:63)
    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:55:63)
    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:40:17)
    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:55:63)
    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:55:63)
    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:55:63)
    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:55:63)
    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:55:63)
    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:55:63)
    at hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:40:17)
    at Object.hasBinary (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/is-binary.js:55:63)
    at Encoder.encode (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io-parser/dist/index.js:38:29)
    at Client._packet (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io/dist/client.js:169:44)
    at Socket.packet (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io/dist/socket.js:160:21)
    at /home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io/dist/socket.js:274:18
    at /home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/lib/socket-base.js:325:28
    at tryCatcher (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/testuser/.cache/Cypress/7.3.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:461:21)

In this case, this problem occurs intermittently.

@poponuts
Copy link

I had to downgrade to 6.4.0 again as this is happening to me too. It is a permanent issue from my end on particular cy.request and not intermittently.

@sainthkh
Copy link
Contributor

sainthkh commented May 25, 2021

The given example wasn't reproducible with Ubuntu 20.04. But desktop-integration-test suite failed every time on my local Ubuntu with cypress run. I'm using the case.

@cypress-bot cypress-bot bot added the stage: needs review The PR code is done & tested, needs review label May 25, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 26, 2021

The code for this is done in cypress-io/cypress#16641, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 7, 2021

Released in 7.5.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v7.5.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug v7.3.0 🐛 Issue present since 7.3.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants