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

WebSocket is already in CLOSING or CLOSED state. Randomly Facing this error and hence failing the Cypress Tests #7180

Closed
Prashant-Kan opened this issue Apr 29, 2020 · 6 comments · Fixed by #7981
Assignees

Comments

@Prashant-Kan
Copy link

Prashant-Kan commented Apr 29, 2020

Current behavior:

When we execute our cypress test, it randomly throws the below error

WebSocket is already in CLOSING or CLOSED state. 

As per our flow, if out automation steps gets pass we execute a cypress Tasks to update the result file for the TestCase status (Pass or Fail). In that Tasks there isn't any database connection. Its just simply uses node command to update a file in fixture folder to set status as pass or fail.

Randomly, when this task is executed the cypress hangs there and end up in a error with WebSocket is already in Closing or Closed State+

We found that after upgrading to latest version 4.4.0 and more It runs very slowly and when executed cy.task() it stucks there randomly. If we revert back to 3.4.1 then its stable. Working normally.

Desired behavior:

The tests should not hold and throws any error like Websocket

Test code to reproduce

Random failure. We are trying to reproduce the steps. But didn't knew how.
#6945
#6458

We have gone through the above issues but didn't get success. Also, have read other socket problem but got fail on each.

Versions

After 3.4.1 to latest version 4.5.0

Operating System : Windows 10
Browser: Chrome, Electron

@jennifer-shehane
Copy link
Member

Please provide a reproducible test suite to show the issue - including the cy.task() code you are mentioning where this hangs.

Unfortunately we have to close this issue if a way to reproduce this is not provided as there will be no path forward for investigation.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Apr 30, 2020
@Prashant-Kan
Copy link
Author

Prashant-Kan commented May 2, 2020

Sure Jennifer.

We are working on the reproducible steps Will share when we find that.
As its random, so hard to find the exact reproducible steps.

Can you give any reference where the random bug has a reproducible steps ?

meanwhile,
cy.task() is to execute the node command to write the result of the executed testcase in (*.md) file.

import * as fs from "fs";
import * as path from "path";
const resultFile = path.join(#FolderPath#, mdFileNameWithExtension);
ensureFolder()

if (fs.existsSync) then read
else create new file

read and fill the file content
and finally using fs.writeFileSync write the file content

@flotwig
Copy link
Contributor

flotwig commented May 4, 2020

Most likely, this regex needs to be updated to handle "WebSocket is already in CLOSING or CLOSED state" as well. We want to retry on these errors instead of failing.

const WEBSOCKET_NOT_OPEN_RE = /^WebSocket is not open/

@testtek
Copy link

testtek commented Jun 29, 2020

Having same issue
#7180 (comment)

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 16, 2020

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

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Jul 16, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 21, 2020

Released in 4.11.0.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jul 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants