Cypress runner crashes after a cy.request() command times out
See original GitHub issueCurrent 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
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:16 (6 by maintainers)
Top Results From Across the Web
Troubleshooting | Cypress Documentation
Open Cypress via cypress open · Go to Developer Tools -> View App Data · This will take you to the directory in...
Read more >Cypress: changing the code while running crashes my tests ...
The only way to make it work again is to manually end the process, then start it again. Has anyone got an idea...
Read more >How To Fix Cypress Crashing Issue In Windows - YouTube
In this video, we will discuss how to fix the cypress crashing issue.New Selenium Batch Starting ...
Read more >cypress-io/cypress - Gitter
all cy command are put in a queue and executed later, so your .utc() call is at ... I'm running true end to...
Read more >cypress-page-object-model - NPM Package Overview - Socket
The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file. Error:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@jennifer-shehane Downgrading to 6.4.0 is not an option for us as we’ve migrated away from
cy.route()
tocy.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 withintercept
.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.