cypress: Error: WebSocket connection closed (in cypress 13.6)
Current behavior
Cypress reports Error: WebSocket connection closed and then stops running tests and cypress.run returns with
{
"failures": 1,
"message": "Could not find Cypress test run results"
}
More context:
- This happens sporadically, in the same spot, for a few projects. Maybe ~10% of the time for those projects.
- This began after upgrading from Cypress 12.17 -> 13.6.1. Before/after volume of this error message:
Desired behavior
Don’t throw errors. Or give more information as to why the errors are happening.
Test code to reproduce
not sure how to reproduce; happens sporadically but consistently
Cypress Version
13.6.1
Node version
18.16.1
Operating System
linux/docker (CI/CD)
Debug Logs
No response
Other
No response
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Reactions: 26
- Comments: 62 (18 by maintainers)
We are intending to look into this in our upcoming sprint.
Thank you everyone for all of your input, especially with stack traces and which version of Cypress. I believe I have identified the source of this error, and will be working on fixing it.
According to stack traces, the uncaught exception is being thrown from
_handleConnectionClose, which is a method that thechrome-remote-interfacepackage implements in order to drain all callbacks pending on a CRI connection with an error when the connection closes and callbacks are pending. One of the changes we made from13.5.1to13.6.0was to upgrade the chrome-remote-interface package to0.33from0.31.3in order to accommodate larger message payloads.It looks like
chrome-remote-interfaceupdated the_handleConnectionClosemethod, changing the values it sends to pending callbacks when the websocket connection closes. I’m currently digging into our own code that interfaces with this module, to determine what we need to change on our end to resolve this issue.I have yet to be able to reproduce this myself, so I cannot yet write regression tests or implement a fix. If the CRI change caused the issue, it may lead to me being able to reproduce this error. However, to expedite this, if anyone can fork https://github.com/cypress-io/cypress-test-tiny or https://github.com/cypress-io/cypress-realworld-app and reproduce the error (even sporadically), that would greatly expedite this process.
I tested on v.13.7.0 and this problem still persist. I updated to v.13.7.0 so that I can fix the cy.screenshoot problem and it did solve it but this web connection closed issue still detected… Please FIX IT ASAP.
@jennifer-shehane we are facing the same issue.
Test code to reproduce not sure how to reproduce; happens sporadically but consistently
Cypress Version 13.3.0 / 13.6.2
Node version 18.15.0
Operating System cypress/base:18.15.0 + browser-tools: circleci/browser-tools@1.4.6 + browser-tools/install-chrome: chrome-version: 119.0.6045.199
Debug Logs No response
Other No response
On Cypress 13.3.0
This happen when the test is finished and the compressing of the video starts.
On Cypress 13.6.2
Again our tests completes, but once its start generating the video failed.
Both cases above are visible only in CircleCI
The websocket errors we are seeing are gone when downgrading to 13.5.x or by disabling videos on 13.6.6, so it definitely seems related
Hi, same issue too: downgraded to 13.5.1.
Having the error, it’s quite annoying, we decided to downgrade to
13.5.x!We have around 100 cypress tests in our project and after upgrading to any version later than 13.5.1 (our current version) some tests start to fail due to that same issue (websocket disconnect)
I’m not sure if I can find a specific case that causes this but it seems like all tests now have a chance to crash due to this issue
Unfortunately we had to rollback to 13.5.1 until this is fixed
Hi everyone, thank you for the expanded logs!
It looks like this is a combination of things:
chrome-remote-interfacepackage is throwing errors when an in-flight CDP command failed due to the WebSocket being closed. Previously, it simply failed silently.I have a tentative fix in review. I’ve built pre-release packages from that branch. If you would like to try them out, please follow the instructions for using prerelease binaries:
linux x64
linux arm64
darwin arm64
darwin x64
windows
Thank you again for your patience while we work through this!
finally I can confirm downgrading ti 13.5.1 works. sorry for the late answer.
i can confirm there has been no decrease in the error for us since upgrading to 13.6.6
@newsuk-apnikolov There are a couple of causes of the websocket error that we can notice from this thread. Yours definitely has something to do with video compression. Some others examples are happening around the time the spec ends/browser closes. We do have this on our radar to investigate further.
A clear way to reproduce 100% of the time would speed up our investigation, but I know it’s mostly intermittent for everyone.
Minimum reproduction for that will probably be just as hard as the websocket one… but i’ll move that to a different issue if it keeps poping up.
this log should be more relevant. Lets focus on 1 problem at a time
I also started seeing the issue sometimes for the first time a few days ago (we upgraded from
13.6.6to13.7.2recently and to the latestcypress/browserscontainer)13.7.2withcypress/browsers:node-20.12.0-chrome-123.0.6312.86-1-ff-124.0.2-edge-123.0.2420.65-1@jennifer-shehane Happened again on my end. Can we reopen?! This issue definitely seems related https://stackoverflow.com/questions/71342595/chrome-websocket-connection-closes-immediately
@jennifer-shehane Just happened again on our CI, using Cypress 13.6.6, Electron 118, Node 20.11.0 EDIT: Also happening with Chrome 122
@jennifer-shehane Yes it’s still happening
Edit: I justed noticed my browser version is waaay behind, probably because Im using Cypress Docker image. Let me try updating and see if this still keeps happening
Update: Im using now latest Cypress version with latests cypress/browser docker image on CI and I didnt experience the websocket issue neither the memory crash issue I was experiencing. The tests are even faster. Let me retry the CI a couple more times again to make sure it will not crash again
Update: @jennifer-shehane I could get rid of the webSocket issues by using the latest Node + latest chrome version + latest Cypress. This combination didn’t get rid of the increased sensibility of Cypress latest version for memory increase, as slight memory usage increases caused crashes.
FYI, we also faced this issue in a recurring test job we set up at Qonto with Cypress. Downgrading to v13.5.1 fixed the issue for us as well.
@jennifer-shehane we remove the video recording after every test and voalya, we stop seeing the nasty socket error. We lost our video debugging but our tests are stable on version 13.6.2.
Please check why this is happen.
Any update on fixing this issue ? The issue still persist in v13.6.2.