cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.09k stars 3.19k forks source link

Cypress crashes with Error: This socket has been ended by the other party #30486

Open pfronczak opened 3 weeks ago

pfronczak commented 3 weeks ago

Current behavior

Despite https://github.com/cypress-io/cypress/issues/27552 being closed as fixed, we are observing very similar behavior in our e2e test runs on cypress 13.14.2. On seemingly random occasions, the tests will fail with:

[2024-10-29T13:05:57.425Z] This socket has been ended by the other party
[2024-10-29T13:05:57.425Z] Error: This socket has been ended by the other party
[2024-10-29T13:05:57.425Z]     at TLSSocket.writeAfterFIN [as write] (node:net:542:14)
[2024-10-29T13:05:57.425Z]     at IncomingMessage.ondata (node:internal/streams/readable:766:22)
[2024-10-29T13:05:57.425Z]     at IncomingMessage.emit (node:events:514:28)
[2024-10-29T13:05:57.425Z]     at addChunk (node:internal/streams/readable:324:12)
[2024-10-29T13:05:57.425Z]     at readableAddChunk (node:internal/streams/readable:297:9)
[2024-10-29T13:05:57.425Z]     at IncomingMessage.push (node:internal/streams/readable:234:10)
[2024-10-29T13:05:57.425Z]     at HTTPParser.parserOnBody (node:_http_common:131:24)
[2024-10-29T13:05:57.425Z]     at TLSSocket.socketOnData (node:_http_client:541:22)
[2024-10-29T13:05:57.425Z]     at TLSSocket.emit (node:events:514:28)
[2024-10-29T13:05:57.425Z]     at addChunk (node:internal/streams/readable:324:12)
[2024-10-29T13:05:57.425Z]     at readableAddChunk (node:internal/streams/readable:297:9)
[2024-10-29T13:05:57.425Z]     at TLSSocket.push (node:internal/streams/readable:234:10)
[2024-10-29T13:05:57.425Z]     at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)

Desired behavior

No response

Test code to reproduce

The error happens on various tests - we haven't seen any correlation with the test scenarios.

Cypress Version

13.14.2

Node version

18.20.4

Operating System

CentOS 7

Debug Logs

[2024-10-29T13:05:57.422Z] 2024-10-29T13:05:57.175Z cypress:network:cors Parsed URL { port: '3003', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' }
[2024-10-29T13:05:57.422Z] 2024-10-29T13:05:57.175Z cypress:network:cors Parsed URL { port: '3003', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' }
[2024-10-29T13:05:57.422Z] 2024-10-29T13:05:57.176Z cypress:network:cors Parsed URL { port: '443', protocol: 'https:', subdomain: '<redacted>>', domain: '<acme>', tld: 'com' }
[2024-10-29T13:05:57.422Z] 2024-10-29T13:05:57.176Z cypress:server:remote-states getting remote state: undefined for: https://<redacted>>.<acme>.com/socket.io/?EIO=4&transport=polling&t=<redacted>&sid=<redacted>
[2024-10-29T13:05:57.423Z] 2024-10-29T13:05:57.176Z cypress:network:cors Parsed URL { port: '3003', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' }
[2024-10-29T13:05:57.423Z] 2024-10-29T13:05:57.176Z cypress:server:remote-states getting remote state: { auth: null, origin: 'http://localhost:3003', strategy: 'http', fileServer: null, domainName: 'localhost', props: { port: '3003', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' } } for: http://localhost:3003
[2024-10-29T13:05:57.423Z] 2024-10-29T13:05:57.177Z cypress:server:stream_buffer stream buffer writeable final called
[2024-10-29T13:05:57.423Z] 2024-10-29T13:05:57.177Z cypress:network:agent addRequest called { isHttps: true, href: 'https://<redacted>>.<acme>.com/socket.io/?EIO=4&transport=polling&t=<redacted>&sid=<redacted>' }
[2024-10-29T13:05:57.423Z] 2024-10-29T13:05:57.177Z cypress:network:agent got family { family: 4, href: 'https://<redacted>>.<acme>.com/socket.io/?EIO=4&transport=polling&t=<redacted>&sid=<redacted>' }
[2024-10-29T13:05:57.423Z] 2024-10-29T13:05:57.179Z cypress:network:cors Parsed URL { port: '3003', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' }
[2024-10-29T13:05:57.423Z] 2024-10-29T13:05:57.179Z cypress:network:cors Parsed URL { port: '3003', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' }
[2024-10-29T13:05:57.423Z] 2024-10-29T13:05:57.179Z cypress:network:cors Parsed URL { port: '443', protocol: 'https:', subdomain: '<redacted>>', domain: '<acme>', tld: 'com' }
[2024-10-29T13:05:57.423Z] 2024-10-29T13:05:57.179Z cypress:server:remote-states getting remote state: undefined for: https://<redacted>>.<acme>.com/socket.io/?EIO=4&transport=polling&t=<redacted>&sid=<redacted>
[2024-10-29T13:05:57.423Z] 2024-10-29T13:05:57.179Z cypress:network:cors Parsed URL { port: '3003', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' }
[2024-10-29T13:05:57.423Z] 2024-10-29T13:05:57.179Z cypress:server:remote-states getting remote state: { auth: null, origin: 'http://localhost:3003', strategy: 'http', fileServer: null, domainName: 'localhost', props: { port: '3003', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' } } for: http://localhost:3003
[2024-10-29T13:05:57.423Z] 2024-10-29T13:05:57.180Z cypress:server:stream_buffer appending chunk to buffer { bytesWritten: 0, chunkLength: 300 }
[2024-10-29T13:05:57.424Z] 2024-10-29T13:05:57.180Z cypress:network:agent addRequest called { isHttps: true, href: 'https://<redacted>>.<acme>.com/socket.io/?EIO=4&transport=polling&t=<redacted>&sid=<redacted>' }
[2024-10-29T13:05:57.424Z] 2024-10-29T13:05:57.180Z cypress:network:agent got family { family: 4, href: 'https://<redacted>>.<acme>.com/socket.io/?EIO=4&transport=polling&t=<redacted>&sid=<redacted>' }
[2024-10-29T13:05:57.424Z] 2024-10-29T13:05:57.181Z cypress:server:stream_buffer stream buffer writeable final called
[2024-10-29T13:05:57.424Z] 2024-10-29T13:05:57.218Z cypress:server:request received status code & headers on request { requestId: 'request485', statusCode: 200, headers: { 'content-type': 'text/html' } }
[2024-10-29T13:05:57.424Z] 2024-10-29T13:05:57.218Z cypress:server:request successful response received { requestId: 'request485' }
[2024-10-29T13:05:57.424Z] 2024-10-29T13:05:57.219Z cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: '/socket.io/?EIO=4&transport=polling&t=<redacted>&sid=<redacted>' }, request: undefined }
[2024-10-29T13:05:57.424Z] 2024-10-29T13:05:57.219Z cypress:network:cors Parsed URL { port: '3003', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' }
[2024-10-29T13:05:57.424Z] 2024-10-29T13:05:57.219Z cypress:server:remote-states getting remote state: { auth: null, origin: 'http://localhost:3003', strategy: 'http', fileServer: null, domainName: 'localhost', props: { port: '3003', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' } } for: http://localhost:3003
[2024-10-29T13:05:57.424Z] 2024-10-29T13:05:57.219Z cypress:network:cors Parsed URL { port: '443', protocol: 'https:', subdomain: '<redacted>>', domain: '<acme>', tld: 'com' }
[2024-10-29T13:05:57.424Z] 2024-10-29T13:05:57.219Z cypress:network:cors Parsed URL { port: '443', protocol: 'https:', subdomain: '<redacted>>', domain: '<acme>', tld: 'com' }
[2024-10-29T13:05:57.424Z] 2024-10-29T13:05:57.219Z cypress:server:remote-states getting primary remote state: { auth: null, origin: 'http://localhost:3003', strategy: 'http', fileServer: null, domainName: 'localhost', props: { port: '3003', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' } }
[2024-10-29T13:05:57.424Z] 2024-10-29T13:05:57.219Z cypress:network:cors Parsed URL { port: '443', protocol: 'https:', subdomain: '<redacted>>', domain: '<acme>', tld: 'com' }
[2024-10-29T13:05:57.424Z] 2024-10-29T13:05:57.219Z cypress:network:cors Parsed URL { port: '443', protocol: 'https:', subdomain: '<redacted>>', domain: '<acme>', tld: 'com' }
[2024-10-29T13:05:57.425Z] 2024-10-29T13:05:57.220Z cypress:network:cors Parsed URL { port: '3003', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' }
[2024-10-29T13:05:57.425Z] 2024-10-29T13:05:57.220Z cypress:server:remote-states getting remote state: { auth: null, origin: 'http://localhost:3003', strategy: 'http', fileServer: null, domainName: 'localhost', props: { port: '3003', protocol: 'http:', subdomain: null, domain: '', tld: 'localhost' } } for: http://localhost:3003
[2024-10-29T13:05:57.425Z] This socket has been ended by the other party
[2024-10-29T13:05:57.425Z] Error: This socket has been ended by the other party
[2024-10-29T13:05:57.425Z]     at TLSSocket.writeAfterFIN [as write] (node:net:542:14)
[2024-10-29T13:05:57.425Z]     at IncomingMessage.ondata (node:internal/streams/readable:766:22)
[2024-10-29T13:05:57.425Z]     at IncomingMessage.emit (node:events:514:28)
[2024-10-29T13:05:57.425Z]     at addChunk (node:internal/streams/readable:324:12)
[2024-10-29T13:05:57.425Z]     at readableAddChunk (node:internal/streams/readable:297:9)
[2024-10-29T13:05:57.425Z]     at IncomingMessage.push (node:internal/streams/readable:234:10)
[2024-10-29T13:05:57.425Z]     at HTTPParser.parserOnBody (node:_http_common:131:24)
[2024-10-29T13:05:57.425Z]     at TLSSocket.socketOnData (node:_http_client:541:22)
[2024-10-29T13:05:57.425Z]     at TLSSocket.emit (node:events:514:28)
[2024-10-29T13:05:57.425Z]     at addChunk (node:internal/streams/readable:324:12)
[2024-10-29T13:05:57.425Z]     at readableAddChunk (node:internal/streams/readable:297:9)
[2024-10-29T13:05:57.425Z]     at TLSSocket.push (node:internal/streams/readable:234:10)
[2024-10-29T13:05:57.425Z]     at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
[2024-10-29T13:05:57.425Z] 2024-10-29T13:05:57.226Z cypress:server:util:socket_allowed allowed socket closed, removing { localPort: 42336 }
[2024-10-29T13:05:57.425Z] 2024-10-29T13:05:57.228Z cypress:server:cloud:api request to url: POST https://api.cypress.io/exceptions with params: {"body":{"err":{"name":"Error","message":"This socket has been ended by the other party","stack":"Error: This socket has been ended by the other party\n    at TLSSocket.writeAfterFIN [as write] (node:net:542:14)\n    at IncomingMessage.ondata (node:internal<stripped-path>readable:766:22)\n    at IncomingMessage.emit (node:events:514:28)\n    at addChunk (node:internal<stripped-path>readable:324:12)\n    at readableAddChunk (node:internal<stripped-path>readable:297:9)\n    at IncomingMessage.push (node:internal<stripped-path>readable:234:10)\n    at HTTPParser.parserOnBody (node:_http_common:131:24)\n    at TLSSocket.socketOnData (node:_http_client:541:22)\n    at TLSSocket.emit (node:events:514:28)\n    at addChunk (node:internal<stripped-path>readable:324:12)\n    at readableAddChunk (node:internal<stripped-path>readable:297:9)\n    at TLSSocket.push (node:internal<stripped-path>readable:234:10)\n    at TLSWrap.onStreamRead (node:internal<stripped-path>stream_base_commons:190:23)"},"version":"13.14.2","osName":"linux","osVersion":"Red Hat Linux - ","osCpus":[{"model":"Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz","speed":2999,"times":{"user":45560,"nice":3870,"sys":18040,"idle":434620,"irq":0}},{"model":"Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz","speed":2999,"times":{"user":48970,"nice":3640,"sys":20290,"idle":480840,"irq":0}},{"model":"Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz","speed":2999,"times":{"user":47770,"nice":4000,"sys":20180,"idle":456950,"irq":0}},{"model":"Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz","speed":2999,"times":{"user":56180,"nice":4190,"sys":19360,"idle":467330,"irq":0}},{"model":"Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz","speed":2999,"times":{"user":77130,"nice":2680,"sys":19800,"idle":487910,"irq":0}},{"model":"Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz","speed":2999,"times":{"user":40050,"nice":2770,"sys":15420,"idle":527290,"irq":0}},{"model":"Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz","speed":2999,"times":{"user":42530,"nice":2410,"sys":15860,"idle":522360,"irq":0}},{"model":"Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz","speed":2999,"times":{"user":44280,"nice":2590,"sys":16450,"idle":521780,"irq":0}}],"osMemory":{"free":12126146560,"total":16169238528}},"headers":{"x-os-name":"linux","x-cypress-version":"13.14.2"}} and token: undefined
[2024-10-29T13:05:57.426Z] 2024-10-29T13:05:57.229Z cypress:network:agent addRequest called { isHttps: true, href: 'https://api.cypress.io/exceptions' }
[2024-10-29T13:05:57.426Z] 2024-10-29T13:05:57.229Z cypress:network:connect beginning getAddress { hostname: 'api.cypress.io', port: 443 }
[2024-10-29T13:05:57.426Z] 2024-10-29T13:05:57.230Z cypress:server:browsers:electron closed event fired
[2024-10-29T13:05:57.426Z] 2024-10-29T13:05:57.230Z cypress:server:windows error removing all extensions { err: TypeError: Object has been destroyed at Object.j (<embedded>:2753:127297) at BrowserWindow.<anonymous> (<embedded>:2753:141101) at Object.onceWrapper (node:events:629:26) at BrowserWindow.emit (node:events:526:35) at <embedded>:2759:19253 at tryCatcher (/home/container_jenkins/.cache/Cypress/13.14.2/Cypress/resources/app/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/home/container_jenkins/.cache/Cypress/13.14.2/Cypress/resources/app/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (/home/container_jenkins/.cache/Cypress/13.14.2/Cypress/resources/app/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromise0 (/home/container_jenkins/.cache/Cypress/13.14.2/Cypress/resources/app/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/home/container_jenkins/.cache/Cypress/13.14.2/Cypress/resources/app/node_modules/bluebird/js/release/promise.js:694:18) at _drainQueueStep (/home/container_jenkins/.cache/Cypress/13.14.2/Cypress/resources/app/node_modules/bluebird/js/release/async.js:138:12) at _drainQueue (/home/container_jenkins/.cache/Cypress/13.14.2/Cypress/resources/app/node_modules/bluebird/js/release/async.js:131:9) at Async._drainQueues (/home/container_jenkins/.cache/Cypress/13.14.2/Cypress/resources/app/node_modules/bluebird/js/release/async.js:147:5) at Immediate._onImmediate (/home/container_jenkins/.cache/Cypress/13.14.2/Cypress/resources/app/node_modules/bluebird/js/release/async.js:17:14) at process.processImmediate (node:internal/timers:476:21), extensions: undefined }
[2024-10-29T13:05:57.427Z] 2024-10-29T13:05:57.230Z cypress:server:browsers browser instance exit event received { code: undefined, signal: undefined }
[2024-10-29T13:05:57.427Z] 2024-10-29T13:05:57.230Z cypress:server:preprocessor removeFile /home/jenkins/workspace/<spec_file>.cy.ts
[2024-10-29T13:05:57.427Z] 2024-10-29T13:05:57.230Z cypress:server:preprocessor base emitter plugin close event
[2024-10-29T13:05:57.427Z] 2024-10-29T13:05:57.230Z cypress:server:preprocessor base emitter native close event
[2024-10-29T13:05:57.427Z] 2024-10-29T13:05:57.231Z cypress:server:browsers:electron clearInstanceState called with options { options: {} }
[2024-10-29T13:05:57.427Z] 2024-10-29T13:05:57.231Z cypress:server:browsers:electron closing remote interface client
[2024-10-29T13:05:57.427Z] 2024-10-29T13:05:57.231Z cypress:server:browsers:cri-client closing
[2024-10-29T13:05:57.427Z] 2024-10-29T13:05:57.231Z cypress:server:browsers:cri-client closing cri client { closed: false, target: '22C7A8C3448B5CCBAC62CC8B0B0BCAC2' }
[2024-10-29T13:05:57.427Z] 2024-10-29T13:05:57.231Z cypress:server:browsers:cdp-connection:22C7A8C3448B5CCBAC62CC8B0B0BCAC2 disconnect of target 22C7A8C3448B5CCBAC62CC8B0B0BCAC2 requested. { terminated: false, connection: true, reconnection: false }
[2024-10-29T13:05:57.427Z] 2024-10-29T13:05:57.231Z cypress:server:browsers browsers.kill called with no active instance
[2024-10-29T13:05:57.427Z] 2024-10-29T13:05:57.231Z cypress:proxy:http:util:prerequests metrics: { browserPreRequestsReceived: 582, proxyRequestsReceived: 445, immediatelyMatchedRequests: 232, unmatchedRequests: 1, unmatchedPreRequests: 107 }
[2024-10-29T13:05:57.428Z] 2024-10-29T13:05:57.231Z cypress:webpack close /home/jenkins/workspace/<spec_file>.cy.ts
[2024-10-29T13:05:57.428Z] 2024-10-29T13:05:57.235Z cypress:server:browsers:browser-cri-client Target.targetDestroyed { event: { targetId: '22C7A8C3448B5CCBAC62CC8B0B0BCAC2' }, closing: true, closed: false, resettingBrowserTargets: false }
[2024-10-29T13:05:57.428Z] 2024-10-29T13:05:57.235Z cypress:server:browsers:cri-client closing
[2024-10-29T13:05:57.701Z] 2024-10-29T13:05:57.425Z cypress:cli child event fired { event: 'exit', code: 1, signal: null }
[2024-10-29T13:05:57.701Z] 2024-10-29T13:05:57.426Z cypress:cli Stopping Xvfb
[2024-10-29T13:05:57.702Z] 2024-10-29T13:05:57.427Z cypress:cli child event fired { event: 'close', code: 1, signal: null }
[2024-10-29T13:05:57.702Z] error Command failed with exit code 1.
[2024-10-29T13:05:57.702Z] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[2024-10-29T13:05:57.702Z] ERROR: "cy --spec cypress/e2e/\*\*/\*.cy.\* --reporter junit --reporter-options mochaFile\=cypress/reports/output-\[hash\].xml\,jenkinsMode\=true" exited with 1.
[2024-10-29T13:05:57.702Z] error Command failed with exit code 1.

Other

No response

hariseldon1267 commented 1 day ago

we've been having this same issue for a couple of months now on a couple of recent versions of cypress - 13.13.2 and 13.15.something test code is not at fault - some of the simplest and shortest specs fail due to crash while more complex long ones pass

i work with 2 repos and the problem is only in one of them

also behaviour is different on different kinds of environments on review stages (gitlab ci) the error sometimes occurs but then test passes on retry on production like stages the same tests fail all the time, retries don't help in both cases exactly the same error, nothing to do with tests or the app - just a crash

tried changing browser to electron - didn't help also tried experimentalMemoryManagement both true and false - didn't help numTestsKeptInMemory is 0