-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: Unhandled "WebSocket connection closed" when CDP connection is unstable #29830
Conversation
3 flaky tests on run #56153 ↗︎
Details:
cypress/e2e/commands/net_stubbing.cy.ts • 3 flaky tests • 5x-driver-webkit
|
Co-authored-by: Mike McCready <66998419+MikeMcC399@users.noreply.github.com>
import type { CdpCommand } from './cdp_automation' | ||
import Debug from 'debug' | ||
|
||
const debug = Debug('cypress:server:browsers:cdp-command-queue') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How chatty will these logs be? Do we want to make some of them verbose and some of them non-verbose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not very chatty - commands are only pushed into the command queue when they come in while the websocket connection is unexpectedly disconnected. params might be a larger payload, though, and could benefit from a verbose (or removal, as it's not pertinent to the command queue operations)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in fc52033
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. I like that we're iteratively refactoring a lot of this stuff. Nice work!
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Additional details
When CDP throws certain errors on a command, CriClient enqueues the original command and attempt to reconnect to CDP. When CDP reconnects, CriClient tries to send this command again, after restoring subscriptions and enablements. This bug appears to occur when CDP disconnects immediately after reconnecting while a previously enqueued command is pending.
The fix is to re-enqueue failed commands upon reconnect, and attempt to reconnect again.
This PR includes that fix, as well as some quality of life refactors to CriClient:
Steps to test
The original issue is very difficult to reproduce - the fix is expected due to new tests that produce the issue. Typical CI & manual testing is sufficient.
How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?