question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cypress crashes on websocket upgrade request over https after update from 9.7.0 to 10.0.3

See original GitHub issue

Current behavior

After I updated my Cypress Version from 9.7.0 to 10.0.3 Cypress crashes on all my tests, which are executed against our test environment. The same tests on localhost are still working. On the test environment I use a client certificate for authentication. I can start the test and while its running, Cypress crashes with the following error, when my application tries to open a websocket connection over https:

Cannot read properties of undefined (reading 'port')
TypeError: Cannot read properties of undefined (reading 'port')
    at ClientCertificateStore.getClientCertificateAgentOptionsForUrl (C:\Users\U807050\AppData\Local\Cypress\Cache\10.0.3\Cypress\resources\app\packages\network\lib\client-certificates.js:128:34)
    at C:\Users\U807050\AppData\Local\Cypress\Cache\10.0.3\Cypress\resources\app\packages\network\lib\agent.js:133:81
    at getFirstWorkingFamily (C:\Users\U807050\AppData\Local\Cypress\Cache\10.0.3\Cypress\resources\app\packages\network\lib\agent.js:87:16)
    at CombinedAgent.addRequest (C:\Users\U807050\AppData\Local\Cypress\Cache\10.0.3\Cypress\resources\app\packages\network\lib\agent.js:129:16)
    at new ClientRequest (node:_http_client:305:16)
    at Object.request (node:https:353:10)
    at Array.stream (C:\Users\U807050\AppData\Local\Cypress\Cache\10.0.3\Cypress\resources\app\node_modules\http-proxy\lib\http-proxy\passes\ws-incoming.js:103:80)
    at ProxyServer.<anonymous> (C:\Users\U807050\AppData\Local\Cypress\Cache\10.0.3\Cypress\resources\app\node_modules\http-proxy\lib\http-proxy\index.js:81:21)
    at ServerE2E.proxyWebsockets (C:\Users\U807050\AppData\Local\Cypress\Cache\10.0.3\Cypress\resources\app\packages\server\lib\server-base.js:312:26)
    at ServerE2E.onUpgrade (C:\Users\U807050\AppData\Local\Cypress\Cache\10.0.3\Cypress\resources\app\packages\server\lib\server-base.js:381:21)
    at Server.<anonymous> (C:\Users\U807050\AppData\Local\Cypress\Cache\10.0.3\Cypress\resources\app\packages\server\lib\server-e2e.js:60:67)
    at C:\Users\U807050\AppData\Local\Cypress\Cache\10.0.3\Cypress\resources\app\packages\server\lib\server-base.js:390:28
    at Array.map (<anonymous>:null:null)
    at ServerE2E.onSniUpgrade (C:\Users\U807050\AppData\Local\Cypress\Cache\10.0.3\Cypress\resources\app\packages\server\lib\server-base.js:389:25)
    at Server._onUpgrade (C:\Users\U807050\AppData\Local\Cypress\Cache\10.0.3\Cypress\resources\app\packages\https-proxy\lib\server.js:97:17)
    at Server.emit (node:events:390:28)
    at Server.emit (node:domain:475:12)
    at onParserExecuteCommon (node:_http_server:727:14)
    at onParserExecute (node:_http_server:640:3)

After some debugging I could figure out the following problem: _.assign(options, clientCertificateStore.getClientCertificateAgentOptionsForUrl(options.uri)) (https://github.com/cypress-io/cypress/blob/develop/packages/network/lib/agent.ts#L192) here the options do not have a uri property. because of this in the client.certificates.js (https://github.com/cypress-io/cypress/blob/develop/packages/network/lib/client-certificates.ts#L1540) the requestUrl is undefined, which leads Cypress to crash.

At this point _.assign(options, clientCertificateStore.getClientCertificateAgentOptionsForUrl(options.uri)), the options has the following structure: options.txt As you can see, there is no uri property…

I could not figure out, why it was working before the Cypress update. Maybe it wasn’t working to but Cypress could handle the error.

And maybe there is some connection to this Issue: https://github.com/cypress-io/cypress/issues/19722

Desired behavior

Cypress should not crash, when an application tries to open a websocket connection over https.

Test code to reproduce

describe('Open Application with websockets', () => {
    it('Open Application with websockets', () => {
        cy.visit('https://websocketstest.com/')
    });

});

Cypress Version

10.0.3

Other

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:5
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
SydneyOConnor2022commented, Jul 7, 2022

Same issue here with 10.3.0. When is it resolved? I don’t wanna go back to Version 9.7.

Cannot read properties of undefined (reading 'port') TypeError: Cannot read properties of undefined (reading 'port') at ClientCertificateStore.getClientCertificateAgentOptionsForUrl (xxxxxx\node_modules\.bin\cypressbin\10.3.0\Cypress\resources\app\packages\network\lib\client-certificates.js:127:34)

3reactions
AtofStrykercommented, Jun 17, 2022

Hey @MJohner. Sorry for the delay! I was able to add your code to the reproduction repository and was able to reproduce it quite easily 😄 . Next step is to get this issue routed over to a team to prioritize .

Repository is up to date here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changelog - Cypress Documentation
Fixed an issue with Angular Component Testing where urls within SASS/SCSS files were not being correctly resolved which could result in incomplete styling....
Read more >
Sometimes cypress seems to block the update of the DOM ...
Cypress tries to wait for the page to finish loading before executing the commands, so perhaps the websocket interaction goes un-noticed in ...
Read more >
cypress: Versions - Openbase
Upgraded the bundled node version shipped with Cypress from 16.5.0 to 16.13.2 . ... Updated the cy.request() log message to hide the origin...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found