cypress-io / cypress

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

Cypress 9.0.0 + Node 17.1 (Win 11) Crashes #18914

Closed JamShady closed 2 years ago

JamShady commented 2 years ago

Current behavior

Setup:

When I use Cypress 9.0.0 and Node 17.1 (i.e. latest versions), Cypress opens up and displays the sample tests, but clicking any one of them results in the following error (non-important folder names redacted for privacy):

Title: Error running plugin

Message: The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file ([appDir]\cypress\plugins\index.js)

Stack trace:

Error: The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (`[appDir]\cypress\plugins\index.js`)
    at Object.get (C:\Users\[user]\AppData\Local\Cypress\Cache\9.0.0\Cypress\resources\app\packages\server\lib\errors.js:1043:15)
    at EventEmitter.handleError (C:\Users\[user]\AppData\Local\Cypress\Cache\9.0.0\Cypress\resources\app\packages\server\lib\plugins\index.js:189:20)
    at EventEmitter.emit (node:events:394:28)
    at ChildProcess.<anonymous> (C:\Users\[user]\AppData\Local\Cypress\Cache\9.0.0\Cypress\resources\app\packages\server\lib\plugins\util.js:19:22)
    at ChildProcess.emit (node:events:394:28)
    at emit (node:internal/child_process:920:12)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)

If I downgrade either/both to Cypress 8.7, or Node 16.13 (LTS version), then everything works fine and as expected, i.e.

Desired behavior

Cypress 9.0 should run as expected with Node 17.1

Test code to reproduce

No test code required, it'll fail running the examples

Cypress Version

9.0.0

Other

No response

jennifer-shehane commented 2 years ago

What is the code that you're running in your plugins file? It sounds like the code you are executing in that file may be incompatible with Node 17.1+.

JamShady commented 2 years ago

As stated, literally nothing. It's a completely clean, vanilla, virgin, [insert any other applicable adjective] install of Cypress.

The file contents are literally:


// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

/**
 * @type {Cypress.PluginConfig}
 */
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
  // `on` is used to hook into various events Cypress emits
  // `config` is the resolved Cypress config
}
dan-kirberger commented 2 years ago

Same thing here (on mac), good point about it being limited to Node 17 only. We had the same issue in our apps when moving to node 17 (not cypress related).

You'll need (I added this on the terminal before launching cypress):

NODE_OPTIONS=--openssl-legacy-provider

I found that here when troubleshooting our local app building issue: https://github.com/webpack/webpack/issues/14532

Whatever is happening under the hood in Cypress is due to this same underlying ssl change in node 17 I guess? Adding that environment variable fixed Cypress 9 for me on node 17.

At the very least, could this underlying error be bubbled up for us? Something is swallowing it.

inqom-visma-qa commented 2 years ago

Same here

Windows10 / Cypress9.0.0 / Node17.0.1

gustawx commented 2 years ago

I have the same problem.

As above: Windows 10 / Cypress 9.0.0 / Node 17.0.1

mateuszmichna commented 2 years ago

Same here. Vanilla install of Cypress 9.0.0 + node 17.0.1.

Can't run any (even dummy) test, because of this error.

Downgrading Cypress to 8.7.0 resolved that issue.

Krisell commented 2 years ago

Same problem for us on macOS and Node.js 17.1.0 with Cypress 9.0.0 and 9.1.0. Solved by setting NODE_OPTIONS=--openssl-legacy-provider

BlueWinds commented 2 years ago

As another temporary workaround, you can also set "nodeVersion": "bundled" in your cypress config - this will cause the plugins process to be executed under node 16, bundled with cypress, which doesn't show the error.

With that said, these are just workarounds, and I'm tracking down the root cause now.

BlueWinds commented 2 years ago

Ok, so looking into the issue with cypress + node 17, it appears the following:

Adding NODE_OPTIONS=--openssl-legacy-provider when we spawn the plugins process fixes this under node 17, but it also breaks node 16 - which means I need to query the node version before launching the plugin process and only add it for node 17+. Not terrible, just still working through it.

Anyway, these are just today's research notes. The workarounds remain the same - set "nodeVersion": "bundled", launch node with NODE_OPTIONS=--openssl-legacy-provider, or use node 16.

fugazi commented 2 years ago

I am facing with the same error with Cypress 9.1.0. which file should I add "nodeVersion": "bundled" ? I don't know as long as cypress.json or package.json Thanks!!

BlueWinds commented 2 years ago

I am facing with the same error with Cypress 9.1.0. which file should I add "nodeVersion": "bundled" ? I don't know as long as cypress.json or package.json Thanks!!

In cypress.json.

cypress-bot[bot] commented 2 years ago

The code for this is done in cypress-io/cypress#19094, but has yet to be released. We'll update this issue and reference the changelog when it's released.

BlueWinds commented 2 years ago

This should go out early next week in the 9.1.1 patch release.

cypress-bot[bot] commented 2 years ago

Released in 9.1.1.

This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v9.1.1, please open a new issue.