NeuraLegion / cypress-har-generator

Cypress plugin for generating HTTP Archive (HAR) files captures network requests during Cypress tests.
https://www.npmjs.com/package/@neuralegion/cypress-har-generator
MIT License
80 stars 18 forks source link

cy.recordHar() results in Websocket connection closed error messages #317

Open krikkrob opened 1 year ago

krikkrob commented 1 year ago

Description After updating cypress-har-generator from version 5.3.7 to 5.16.4 I see a lot of error messages when performing test runs. Those error messages won't finish the test execution, but the error messages make it hard to consume. They are shown pretty much after every test.

Stack trace

CYPRESS-HAR-GENERATOR 49211: Failed request: 50867.306. Reason: net::ERR_ABORTED
    ✓ should add and remove activity from activity list (12835ms)
CYPRESS-HAR-GENERATOR 49211: Session 8B0EE4B6FDD91BE4124A1868C5DD6386 associated with request: 50867.307
CYPRESS-HAR-GENERATOR 49211: Session 8B0EE4B6FDD91BE4124A1868C5DD6386 associated with request: 50867.308
CYPRESS-HAR-GENERATOR 49211: Session 8B0EE4B6FDD91BE4124A1868C5DD6386 associated with request: 50867.309
CYPRESS-HAR-GENERATOR 49211: Failed request: 50867.307. Reason: net::ERR_ABORTED
CYPRESS-HAR-GENERATOR 49211: Failed request: 50867.308. Reason: net::ERR_ABORTED
CYPRESS-HAR-GENERATOR 49211: Failed request: 50867.309. Reason: net::ERR_ABORTED
CYPRESS-HAR-GENERATOR 49211: Session 8B0EE4B6FDD91BE4124A1868C5DD6386 associated with request: 50867.310
CYPRESS-HAR-GENERATOR 49211: Failed request: 50867.310. Reason: net::ERR_ABORTED
CYPRESS-HAR-GENERATOR 49211: Chrome Debugging Protocol disconnected
CYPRESS-HAR-GENERATOR 49211: We encountered an issue while initializing the target for the session: 573D09E8A9BAE05B3DD0409419F304FE.
CYPRESS-HAR-GENERATOR 49211: The information about the target is as follows: {"targetId":"426A4FC284C64A86EBFE324497E998AB","type":"service_worker","title":"Service Worker https://xyz/desktop-notifications-service-worker.js?cdnDomain=xyz.xyz","url":"xyz?cdnDomain=xyz.xyz","attached":true,"canAccessOpener":false,"browserContextId":"99A5C94DD10A5994FBEBBF67F0575AA6"}
⚠ Unable to attach to the target (e.g. page, worker, etc). 

Possible reasons for the failure include:
  - Chrome not running in headless mode.
  - The target may have closed during initialization.
  - The target may have crashed due to memory issues.

Please open an issue on the repository: https://github.com/NeuraLegion/cypress-har-generator/issues for assistance.

The stack trace for this error is:
Error: WebSocket connection closed
    at /Users/xxx/git/smoke-tests/node_modules/chrome-remote-interface/lib/chrome.js:94:35
    at Chrome._handleConnectionClose (xyz/git/sre-smoke-tests/node_modules/chrome-remote-interface/lib/chrome.js:256:13)
    at WebSocket.<anonymous> (xyz/git/sre-smoke-tests/node_modules/chrome-remote-interface/lib/chrome.js:114:26)
    at Object.onceWrapper (node:events:628:26)
    at WebSocket.emit (node:events:513:28)
    at WebSocket.emit (node:domain:489:12)
    at WebSocket.emitClose (xyz/sre-smoke-tests/node_modules/ws/lib/websocket.js:246:10)
    at Socket.socketOnClose (xyz/node_modules/ws/lib/websocket.js:1148:15)
    at Socket.emit (node:events:513:28)
    at Socket.emit (node:domain:489:12)
    at TCP.<anonymous> (node:net:301:12)
⚠ Unable to attach to the target (e.g. page, worker, etc). 

Possible reasons for the failure include:
  - Chrome not running in headless mode.
  - The target may have closed during initialization.
  - The target may have crashed due to memory issues.

Please open an issue on the repository: https://github.com/NeuraLegion/cypress-har-generator/issues for assistance.

The stack trace for this error is:
Error: WebSocket connection closed
    at /xyz/node_modules/chrome-remote-interface/lib/chrome.js:94:35
    at Chrome._handleConnectionClose (/xyz/node_modules/chrome-remote-interface/lib/chrome.js:256:13)
    at WebSocket.<anonymous> (xyz/node_modules/chrome-remote-interface/lib/chrome.js:114:26)
    at Object.onceWrapper (node:events:628:26)
    at WebSocket.emit (node:events:513:28)
    at WebSocket.emit (node:domain:489:12)
    at WebSocket.emitClose (/xyz/node_modules/ws/lib/websocket.js:246:10)
    at Socket.socketOnClose (xyz/node_modules/ws/lib/websocket.js:1148:15)
    at Socket.emit (node:events:513:28)
    at Socket.emit (node:domain:489:12)
    at TCP.<anonymous> (node:net:301:12)
CYPRESS-HAR-GENERATOR 49211: We encountered an issue while initializing the target for the session: 677BCB823ED3F2DBF33E11FD0BE23ABB.
CYPRESS-HAR-GENERATOR 49211: The information about the target is as follows: {"targetId":"426A4FC284C64A86EBFE324497E998AB","type":"service_worker","title":"Service Worker https://xyz.xyz","url":"xyz.xyz/?cdnDomain=xyz.xyz","attached":true,"canAccessOpener":false,"browserContextId":"99A5C94DD10A5994FBEBBF67F0575AA6"}
CYPRESS-HAR-GENERATOR 49211: Attempting to connect to Chrome Debugging Protocol
CYPRESS-HAR-GENERATOR 49211: Connected to Chrome Debugging Protocol
CYPRESS-HAR-GENERATOR 49211: Session A97453BC80AFB6CEE9208E3ABFEFC326 associated with request: 50867.311
CYPRESS-HAR-GENERATOR 49211: Failed request: 50867.311. Reason: net::ERR_ABORTED

Environment

Steps to reproduce

MoKhajavi75 commented 1 year ago

Any way to silence this warning?

krikkrob commented 1 year ago

@MohamadKh75 Haven't found a way yet. Are you having the same issue?

MoKhajavi75 commented 1 year ago

@MohamadKh75 Haven't found a way yet. Are you having the same issue?

yep