Skip to content
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

Cannot read properties of undefined (reading 'isServer') #22291

Closed
fragglebob opened this issue Jun 13, 2022 · 36 comments
Closed

Cannot read properties of undefined (reading 'isServer') #22291

fragglebob opened this issue Jun 13, 2022 · 36 comments
Labels
pkg/electron This is due to an issue in the packages/electron directory type: bug

Comments

@fragglebob
Copy link

Current behavior

Since upgrading to Cypress 10, we are getting crashes in our CI with the following error:

Cannot read properties of undefined (reading 'isServer')
TypeError: Cannot read properties of undefined (reading 'isServer')
    at TLSWrap.onerror (node:_tls_wrap:411:27)
  cypress:network:agent addRequest called { isHttps: true, href: 'https://api.cypress.io/exceptions' } +49ms
  cypress:network:agent got family { family: 4, href: 'https://api.cypress.io/exceptions' } +0ms
  cypress:server:browsers killing browser process +9s
  cypress:server:browsers:chrome closing remote interface client +9s
  cypress:server:browsers:chrome closing chrome +0ms
  cypress:cli child event fired { event: 'exit', code: 1, signal: null } +2m
  cypress:cli Stopping Xvfb +2m

This is happening almost ever run we do. Hover we are running in 30 machines parallel, and the most I've seen is two machines fail in the same test run.

I found an issue nodejs/node#41501 and PR nodejs/node#41523 that relate to this error above, which seems to have been fixed in Node v16.15.0.

I set up for our tests to run in a custom container image today that is using Node v16.15.1, so I could see if that helps. However I've now realised that cypress has an internal version of node which is being used, v16.13.2 which still has this bug in it from Node.

Desired behavior

Ideal if should not being crashing when this error happens.

As this is an issue with how node is happening an error internally, there is probably some other error happening, but it's breaking before we can see what that is.

Test code to reproduce

Not sure how to reproduce this as I can't work out what is causing the issue.

In nodejs/node#41501 they weren't able to workout what the exact cause was, other than something wrong with the network somewhere.

Cypress Version

10.1.0

Other

No response

@cypress-bot cypress-bot bot added the stage: investigating Someone from Cypress is looking into this label Jun 13, 2022
@AtofStryker
Copy link
Contributor

Hey @fragglebob. Thank you for opening an issue. Have you found a way to reproduce this locally in a reproduction repo or does this only happen in CI with parallel jobs?

Not ideal, but I am wondering if you can verify if this works by creating a custom image similar to this and bumping the node version to 16.15.1, and building a browser image to consume and run your tests in CI.

@fragglebob
Copy link
Author

Unfortunately I've not seen it locally or anyone else.

I had already tried that suggestion of a custom images with v16.15.1 and the same browsers.

I think the version being used by cypress's server is the version bundled in electron. I can see this from a couple of logs that report the node version. However it does start sub processes on the system version.

Is there a way to skip the whole electron start up?

I see electron v20 will have node v16.15.0, but it's still in alpha.

We have some verbose logging on, and I've been trying to see if there is some pattern to when this happens, but not found anything yet.

@darrinmn9
Copy link

I am having a similar issue. For me, It occurs when upgrading from 9.6.1 -> 9.7.0 (electron 100). For my test suite, I can consistently reproduce this issue locally on my mac and in aws codebuild CI docker image - both of which use node v16.14.0. I am not parallelizing tests. What is interesting is that it always fails on the 2nd test in my test suite (the first test passes successfully), but it isn't specific to the actual 2nd test spec. I can move test specs around, comment/delete specs, and it still consistently fails on the 2nd spec that runs.

TypeError: Cannot read properties of undefined (reading 'isServer')
    at TLSWrap.onerror (node:_tls_wrap:411:27)

@AtofStryker
Copy link
Contributor

I think the version being used by cypress's server is the version bundled in electron. I can see this from a couple of logs that report the node version. However it does start sub processes on the system version.

You are right about this. The method I proposed won't work 😞 .

Is there a way to skip the whole electron start up?

I don't think so. Even in run mode, the electron app still starts and runs a few shared processes.

@flotwig @tbiethman do you all have any ideas on this one? It almost seems like we would need to wait until electron releases v20 to update the bundled node version.

@devhid
Copy link

devhid commented Jun 14, 2022

I'm having the same issue:

Cannot read properties of undefined (reading 'isServer')
TypeError: Cannot read properties of undefined (reading 'isServer')
    at TLSWrap.onerror (node:_tls_wrap:411:27)

POST /logging_client_events 200 95.593 ms - -
The Test Runner unexpectedly exited via a exit event with signal SIGABRT

Please search Cypress documentation for possible solutions:

https://on.cypress.io

Check if there is a GitHub issue describing this crash:

https://github.com/cypress-io/cypress/issues

Consider opening a new issue.

----------

Platform: darwin-x64 (21.4.0)
Cypress Version: 10.1.0

This is a (fairly) minimal reproducible example: https://github.com/devhid/cypress-v10-issue

In my case, I'm trying to run Lighthouse on some sample websites for both mobile and desktop viewports, but I get the mentioned error at the end of the test run.

My Lighthouse tests run fine on Cypress v9.6.0:

❯ npx cypress --version    
Cypress package version: 9.6.0
Cypress binary version: 9.6.0
Electron version: 15.5.1
Bundled Node version: 16.5.0

But not on Cypress v10.1.0:

❯ npx cypress --version
Cypress package version: 10.1.0
Cypress binary version: 10.1.0
Electron version: 18.0.4
Bundled Node version: 16.13.2

I'm using the following Node / NPM versions:

❯ node --version  
v16.14.2

❯ npm --version   
8.10.0

Steps:

  1. npm i
  2. npx cypress open
  3. Run lighthouse.cy.js

@fragglebob
Copy link
Author

I have been able to reproduce the error in the repo @devhid has shared locally. It's doesn't happen every time for me, but it happens often enough.

@fragglebob
Copy link
Author

I started Cypress electron app directly with an debugger attached and have some extra info on the underlying error, that node is struggling to handle.

code: "ERR_SSL_SSLV3_ALERT_CLOSE_NOTIFY"
function: "OPENSSL_internal"
library: "SSL routines"
reason: "SSLV3_ALERT_CLOSE_NOTIFY"
message: "140252445026280:error:100003e8:SSL routines:OPENSSL_internal:SSLV3_ALERT_CLOSE_NOTIFY:../../third_party/boringssl/src/ssl/tls_record.cc:594:SSL alert number 0\n"
stack: "Error: 140252445026280:error:100003e8:SSL routines:OPENSSL_internal:SSLV3_ALERT_CLOSE_NOTIFY:../../third_party/boringssl/src/ssl/tls_record.cc:594:SSL alert number 0\n\n\n"

Screenshot 2022-06-14 at 20 59 36

@fragglebob
Copy link
Author

Ok, I've done some more research into this error.

It seems the owner of TLSWrap was being set to something that wasn't a TLSSocket by a change in Node v16.7.0 nodejs/node#38468 which was later reverted in version v16.14.0.

This is happening because the http/s Agent is reusing an existing socket, and this internal change the owner, so when an error does happen it breaks. The only way I can think to avoid a state in these node versions is to not use keepAlive and avoid connection reuse. Which would probably degrade performance.

@flotwig
Copy link
Contributor

flotwig commented Jun 15, 2022

@fragglebob I'm not surprised to find out it's "something wacky to do with Keep-Alive", the interplay of Keep-Alive and Agents is a really tricky area.

Sounds like the solution is to bump Cypress's internal Node.js version. Looks like Electron 19.0.0 has Node 16.14.2, so it should avoid this.

Would still be nice to have a cleaner reproduction, but at least we have @devhid's sorta flaky repro to test if Electron 19 seems to resolve the issue.

The only way I can think to avoid a state in these node versions is to not use keepAlive and avoid connection reuse. Which would probably degrade performance.

Yeah, removing Keep-Alive would really hinder proxy performance.

@fragglebob
Copy link
Author

@flotwig yep, all that async stuff is complicated.

Yep, a bump to Electron 19 should be good. Which is nicer than having to wait for version 20.

I kinda came up a little script based on some unit tests in node, where I could quickly see what was going on in the owner in different versions.

@AtofStryker AtofStryker added type: bug pkg/electron This is due to an issue in the packages/electron directory labels Jun 16, 2022
@cypress-bot cypress-bot bot added stage: routed to e2e-core and removed stage: investigating Someone from Cypress is looking into this labels Jun 16, 2022
@Amirault
Copy link

I have the same behaviour locally and on ci : cypress version : "9.7.0"

@gavinhenderson
Copy link

I have the same issue on 10.1.0

Is there anything I can do to fix this or do we just have to wait?

@natapg
Copy link

natapg commented Jun 17, 2022

same issue here after migrating to v10

 Cypress:        10.0.3
 Browser:        Custom Chromium 90 (headless)
 Node Version:   v12.22.12

@HannersRipley
Copy link

We had to downgrade to cypress 9.6.1 (which also caused a chain of other downgrades which is very inconvenient). Hopefully this isn't too long in getting fixed or we will need a more involved workaround to prevent this in our CI.

@AtofStryker AtofStryker removed their assignment Jun 17, 2022
@fredysiswanto
Copy link

fredysiswanto commented Jun 18, 2022

same issue here, run local will force-close
windows 11
cypress 10.1.0
browser Chrome v102
node v16.15.1

Screenshot 2022-06-18 092934

@urbany
Copy link

urbany commented Jun 20, 2022

Hi everyone, anyway to circumvent this instead of downgrading to cypress to 9.6.1 ?
Thanks in advance

@AtofStryker
Copy link
Contributor

we are releasing 10.2.0 today, which bumps the electron version to 18.3.0. Unfortunately, the internal node version I believe is still fixed to v16.13.2, so I do not expect this release to fix this issue. This issue likely won't be resolved until we do a major electron version bump.

@id-dan
Copy link

id-dan commented Jun 22, 2022

@AtofStryker you are right, the same issue on 10.2.0
Screenshot 2022-06-22 at 16 52 32

@AtofStryker
Copy link
Contributor

We are discussing as a team to figure out prioritizing an Electron 19.x upgrade to resolve issues like this, as well as one thats are related.

@antoniocl11-w
Copy link

Has there been any solution for this error? The same thing happens to me in github actions

@aangelinsf
Copy link

Just experienced this with 10.3 on macOS 12.4.

@Akash141991
Copy link

Facing the same issue on:

  • Windows 11
  • Cypress 10.3.1
  • Chrome 99 (headless)
  • Node v16.14.0
    Any workaround?

@traxtor182
Copy link

Just experienced this with 10.3

@abinaya-konda
Copy link

experiencing with cypress 10.3, any workaround? This breaks github pipeline!

@charkour
Copy link

charkour commented Aug 1, 2022

experiencing with cypress 10.3, any workaround? This breaks github pipeline!

Our workaround was the re-run the workflow a couple of times and then it worked. We are on Node v16 and npm v8 if for some reason those affect Cypress' ability to run.

@abinaya-konda
Copy link

We are using node 16 and npm 8, running only a few scripts seems to work, but if I execute the entire suite, it always breaks. Is it suggestable to downgrade the cypress version?

@fragglebob
Copy link
Author

I rolled back to version 9 pretty much after constantly running into this on every suite run.

Until cypress is based a newer version of electron. This is just gonna keep happening.

@charkour
Copy link

charkour commented Aug 2, 2022

That's interesting to hear. My team ran into the reported issue once, but haven't had any issues since while using the latest version.

Not sure why there is a discrepancy between users.

@fragglebob
Copy link
Author

I guess it comes down to this being caused by network level errors and the way they are handled.

There must be something in my setup that errors often enough to crash each test suite run.

@fragglebob
Copy link
Author

Good news. Upgraded today to 10.4.0. All seems resolved so far. 10.4 included the update to electron, which doesn't include a version of node where this is an issue anymore.

@AtofStryker
Copy link
Contributor

@fragglebob awesome! Can any others also confirm that 10.4.0 also helps resolve this issue for them?

@Akash141991
Copy link

Resolved for me after upgrading to 10.4.0 :)

@AtofStryker
Copy link
Contributor

I am going to close this since it should be resolved with the electron bump in #22775 which was released in 10.4.0. If this continues to be an issue for some, please let us know so we can discuss and possibly reopen the issue.

@HugoBicudo
Copy link

mesmo problema aqui, executar local irá forçar o fechamento do Windows 11 cypress 10.1.0 navegador Chrome v102 nó v16.15.1

Captura de tela 2022-06-18 092934

conseguiu resolver o problema?

@AtofStryker
Copy link
Contributor

@HugoBicudo el problema debería resolver en la versión más mejor o igual que 10.4.0

@bhadmus
Copy link

bhadmus commented Jul 24, 2023

This issue has resurfaced in version 12. I am still investigating

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/electron This is due to an issue in the packages/electron directory type: bug
Projects
None yet
Development

No branches or pull requests