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

fix: WebSocket Connection Closed crashing from BrowserCriClient #30174

Merged
merged 9 commits into from
Sep 3, 2024

Conversation

cacieprins
Copy link
Contributor

Additional details

When the BrowserCRIClient attaches to a target, it determines if the new target is an "extra target" or not. As a part of this process, it creates a raw CDPClient instance and sends a Fetch.enable command. If this extra target is closed before that command can resolve, CDPClient will throw a WebSocket Connection Closed error. If this error is uncaught, it will crash Cypress.

To fix this, the command is wrapped in try/catch, and logs a debug entry for the error if an error is encountered.

This could have been fixed by using the more resilient CRIClient class, but BrowserCRIClient is fairly complex, and this approach has a smaller change footprint. BrowserCRIClient is a candidate for similar refactors that were made to CRIClient, recently.

Steps to test

As this error is very difficult to reproduce intentionally, the only test available is a unit test.

How has the user experience changed?

PR Tasks

@cacieprins cacieprins changed the title Fix: Further manifestations of WebSocket Closed crashes Fix: WebSocket Connection Closed crashing from BrowserCriClient Sep 3, 2024
@cacieprins cacieprins changed the title Fix: WebSocket Connection Closed crashing from BrowserCriClient fix: WebSocket Connection Closed crashing from BrowserCriClient Sep 3, 2024
@cacieprins cacieprins force-pushed the cacie/30100/browser-cri-client-websocket-closed branch 4 times, most recently from 9fa116f to 931d2f0 Compare September 3, 2024 14:55
Copy link

cypress bot commented Sep 3, 2024

cypress    Run #56927

Run Properties:  status check passed Passed #56927  •  git commit eab555bdae: Merge branch 'develop' into cacie/30100/browser-cri-client-websocket-closed
Project cypress
Branch Review cacie/30100/browser-cri-client-websocket-closed
Run status status check passed Passed #56927
Run duration 17m 30s
Commit git commit eab555bdae: Merge branch 'develop' into cacie/30100/browser-cri-client-websocket-closed
Committer Cacie Prins
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 73
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 5592
View all changes introduced in this branch ↗︎

Warning

No Report: Something went wrong and we could not generate a report for the Application Quality products.

@cacieprins cacieprins merged commit bbe5328 into develop Sep 3, 2024
82 of 84 checks passed
@cacieprins cacieprins deleted the cacie/30100/browser-cri-client-websocket-closed branch September 3, 2024 22:25
gweesin pushed a commit to gweesin/cypress that referenced this pull request Sep 4, 2024
…ess-io#30174)

* catch Fetch.enable errors on extra target in browser CRI

* changelog

* changelog

* changelog

* Update packages/server/test/unit/browsers/browser-cri-client_spec.ts

Co-authored-by: Bill Glesias <bglesias@gmail.com>

* use try/catch instead of .catch for wider unit test support

---------

Co-authored-by: Bill Glesias <bglesias@gmail.com>
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 4, 2024

Released in 13.14.2.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Sep 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants