cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Websocket Connection Closed: When `BrowserCriClient` destroys an extra target while that target is being initialized, the App crashes

Open cacieprins opened this issue 6 months ago • 0 comments

Current behavior

If BrowserCriClient's _onTargetDestroyed event handler is triggered while the _onAttachToTarget event handler is pending the Fetch.enable CRI command, the app can crash with an uncaught exception, Error: WebSocket connection closed.

This is a separate manifestation of the WebSocket connection closed issue that was resolved in the CriClient class in v13.13.1.

Desired behavior

No response

Test code to reproduce

None currently, but should be reproducible with a unit test in packages/server/test/unit/browsers/browser-cri-client_spec.ts

Cypress Version

13.13.1

Node version

18.17.1

Operating System

OSX 14.3

Debug Logs

2024-08-23T01:22:08.390Z cypress:server:browsers:browser-cri-client Target.attachedToTarget { targetId: 'EB14338F830B61BC0944C09E4C812677', type: 'page', title: '', url: '', attached: true, canAccessOpener: false, browserContextId: 'BB40F3CCEE2CA5D8CB25D667E5AB23E2' }
2024-08-23T01:22:08.395Z cypress:server:browsers:browser-cri-client Connect as extra target (id: EB14338F830B61BC0944C09E4C812677)
WebSocket connection closed
2024-08-23T01:22:08.434Z cypress:server:browsers:browser-cri-client Target.targetDestroyed { event: { targetId: 'EB14338F830B61BC0944C09E4C812677' }, closing: false, closed: false, resettingBrowserTargets: false }
2024-08-23T01:22:08.434Z cypress:server:browsers:browser-cri-client Close extra target client (id: %s)
Error: WebSocket connection closed
    at _._handleConnectionClose (<embedded>:628:580021)
    at A.<anonymous> (<embedded>:628:578085)
    at Object.onceWrapper (node:events:629:26)
    at A.emit (node:events:514:28)
    at A.emitClose (<embedded>:628:558309)
    at Socket.H (<embedded>:628:565620)
    at Socket.emit (node:events:514:28)
    at TCP.<anonymous> (node:net:323:12)

Other

No response

cacieprins avatar Aug 23 '24 19:08 cacieprins