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

Do not exit with 0 when running with NODE_OPTIONS #1676

Closed
bahmutov opened this issue May 3, 2018 · 18 comments · Fixed by #4001
Closed

Do not exit with 0 when running with NODE_OPTIONS #1676

bahmutov opened this issue May 3, 2018 · 18 comments · Fixed by #4001
Assignees
Labels
cli type: unexpected behavior User expected result, but got another

Comments

@bahmutov
Copy link
Contributor

bahmutov commented May 3, 2018

bug

When using NODE_OPTIONS=--max_old_space_size=4096 Cypress run through CLI silently fails but the exit code is 0.

  • why is this option affecting the run?
  • why don't we exit with 1?
  • why don't we print the problem?
$ NODE_OPTIONS=--max_old_space_size=4096 DEBUG=cypress:* npm run cypress:open

> [email protected] cypress:open /Users/gleb/git/cypress-test-tiny
> cypress open

  cypress:cli cli starts with arguments ["/Users/gleb/.nvm/versions/node/v8.9.4/bin/node","/Users/gleb/git/cypress-test-tiny/node_modules/.bin/cypress","open"] +0ms
  cypress:cli program parsing arguments +3ms
  cypress:cli opening Cypress +1ms
  cypress:cli parsed cli options {} +129ms
  cypress:cli opening from options {"project":"/Users/gleb/git/cypress-test-tiny"} +0ms
  cypress:cli command line arguments ["--project","/Users/gleb/git/cypress-test-tiny"] +1ms
  cypress:cli verifying Cypress app +0ms
  cypress:cli path to info.json file /Users/gleb/git/cypress-test-tiny/node_modules/cypress/dist/info.json +0ms
  cypress:cli { version: '2.1.0', verifiedVersion: '2.1.0' } +16ms
  cypress:cli installed version is 2.1.0 comparing to 2.1.0 +17ms
  cypress:cli checking if executable exists /Users/gleb/git/cypress-test-tiny/node_modules/cypress/dist/Cypress.app/Contents/MacOS/Cypress +0ms
  cypress:cli path to info.json file /Users/gleb/git/cypress-test-tiny/node_modules/cypress/dist/info.json +2ms
  cypress:cli has verified version 2.1.0 +2ms
  cypress:cli run verification check? false +0ms
  cypress:cli needs XVFB? false +0ms
  cypress:cli spawning Cypress /Users/gleb/git/cypress-test-tiny/node_modules/cypress/dist/Cypress.app/Contents/MacOS/Cypress +0ms
  cypress:cli spawn args ["--project","/Users/gleb/git/cypress-test-tiny","--cwd","/Users/gleb/git/cypress-test-tiny"] { dev: undefined, detached: false, stdio: 'inherit' } +0ms
~/git/cypress-test-tiny on master
$ echo $?
0
@bahmutov bahmutov added type: unexpected behavior User expected result, but got another cli labels May 3, 2018
@bahmutov bahmutov self-assigned this May 3, 2018
@bahmutov
Copy link
Contributor Author

bahmutov commented May 3, 2018

Related to #1675 and #1434

@bahmutov
Copy link
Contributor Author

bahmutov commented May 3, 2018

The option itself is undocumented v8 flag

node --v8-options | grep max_old
  --max_old_space_size (max size of the old space (in Mbytes))

@bahmutov
Copy link
Contributor Author

bahmutov commented May 3, 2018

Some experiments

$ NODE_OPTIONS=--max_old_space_size=4096 node -e 'console.log("hi")'
hi
$ NODE_OPTIONS=--max_old_space_size=9009900 node -e 'console.log("hi")'
hi
$ NODE_OPTIONS=--max_old_space_size=0 node -e 'console.log("hi")'
hi
$ NODE_OPTIONS=--max_old_space_size=1 node -e 'console.log("hi")'
Segmentation fault: 11
$ echo $?
139
$ NODE_OPTIONS= ./node_modules/cypress/dist/Cypress.app/Contents/MacOS/Cypress
Segmentation fault: 11
$ echo $?
139
$ NODE_OPTIONS=--max_old_space_size=4096 ./node_modules/cypress/dist/Cypress.app/Contents/MacOS/Cypress
Segmentation fault: 11

@bahmutov
Copy link
Contributor Author

bahmutov commented May 3, 2018

Electron v1.8.3, v2.0.0 crashes when NODE_OPTIONS is set electron/electron#12695

@jennifer-shehane jennifer-shehane added stage: awaiting external fix A 3rd party bug in Cypress - awaiting release and removed stage: in progress labels May 15, 2018
@nothingismagick
Copy link

Just a hunch - are you running the latest node 8.11.2? There were a great number of improvements in the crypto stack related to cache bloat issues.

@jennifer-shehane
Copy link
Member

@bahmutov
Copy link
Contributor Author

I think this is an interesting bug that surfaces a missing error handling - when we attempt to start the binary, but fail but CLI still thinks everything is great

@beaugunderson
Copy link

beaugunderson commented Aug 21, 2018

On High Sierra cypress segfaults for me if NODE_OPTIONS=--max_old_space_size=4096 or if NODE_OPTIONS="".

I have to unset NODE_OPTIONS for cypress not to segfault.

Versions:

Cypress 3.1.0
macOS 10.13.6
node 10.8.0

@jdcumpson
Copy link

jdcumpson commented Oct 16, 2018

I also was able to start cypress again by unsetting the environment variable,

Node: 8.11.3
Darwin: 17.6.0
Cypress: 3.1.0

Pasting the error code so others may find this via google search.

> ../../node_modules/.bin/cypress open

It looks like this is your first time using Cypress: 3.1.0

 ✖  Verifying Cypress can run <redacted>/Library/Caches/Cypress/3.1.0/Cypress.app
   → Cypress Version: 3.1.0
Cypress failed to start.

This is usually caused by a missing library or dependency.

The error below should indicate which dependency is missing.

https://on.cypress.io/required-dependencies

If you are using Docker, we provide containers with all required dependencies installed.
----------

Command failed: 
<redacted>/Library/Caches/Cypress/3.1.0/Cypress.app/Contents/MacOS/Cypress --smoke-test --ping=674
----------

Platform: darwin (17.6.0)
Cypress Version: 3.1.0

@gcirone
Copy link

gcirone commented Jan 9, 2019

Same issue for me on node 8.13.0 and cypress 3.1.2

@skydever
Copy link

same on my side using the cypress/base:8 image as base image - I have to unset NODE_OPTIONS to pass the verification :/

2019-01-10T14:32:36.824Z cypress:cli verifying Cypress app
2019-01-10T14:32:36.824Z cypress:cli checking environment variables
2019-01-10T14:32:36.825Z cypress:cli checking if executable exists /root/.cache/Cypress/3.1.4/Cypress/Cypress
2019-01-10T14:32:36.827Z cypress:cli Binary is executable? : true
2019-01-10T14:32:36.827Z cypress:cli binaryDir is  /root/.cache/Cypress/3.1.4/Cypress
2019-01-10T14:32:36.827Z cypress:cli Reading binary package.json from: /root/.cache/Cypress/3.1.4/Cypress/resources/app/package.json
2019-01-10T14:32:36.830Z cypress:cli Found binary version 3.1.4 installed in: /root/.cache/Cypress/3.1.4/Cypress
2019-01-10T14:32:36.831Z cypress:cli could not read binary_state.json file
2019-01-10T14:32:36.831Z cypress:cli {}
2019-01-10T14:32:36.831Z cypress:cli is Verified ? undefined
2019-01-10T14:32:36.831Z cypress:cli running binary verification check 3.1.4
It looks like this is your first time using Cypress: 3.1.4

[15:32:36]  Verifying Cypress can run /root/.cache/Cypress/3.1.4/Cypress [started]
2019-01-10T14:32:36.836Z cypress:cli clearing out the verified version
2019-01-10T14:32:36.837Z cypress:cli running smoke test
2019-01-10T14:32:36.837Z cypress:cli using Cypress executable /root/.cache/Cypress/3.1.4/Cypress/Cypress
2019-01-10T14:32:36.837Z cypress:cli needs XVFB? true
2019-01-10T14:32:36.837Z cypress:cli Starting XVFB
2019-01-10T14:32:36.924Z cypress:cli smoke test command: /root/.cache/Cypress/3.1.4/Cypress/Cypress --smoke-test --ping=630
2019-01-10T14:32:37.067Z cypress:cli Smoke test failed: { Error: Command failed: /root/.cache/Cypress/3.1.4/Cypress/Cypress --smoke-test --ping=630
Xlib:  extension "RANDR" missing on display ":99".


    at makeError (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/execa/index.js:172:9)
    at Promise.all.then.arr (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/execa/index.js:277:16)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
  code: null,
  stdout: '',
  stderr: 'Xlib:  extension "RANDR" missing on display ":99".\n',
  failed: true,
  signal: 'SIGSEGV',
  cmd: '/root/.cache/Cypress/3.1.4/Cypress/Cypress --smoke-test --ping=630',
  timedOut: false,
  killed: false }
2019-01-10T14:32:37.152Z cypress:cli Stopping XVFB
[15:32:37]  Verifying Cypress can run /root/.cache/Cypress/3.1.4/Cypress [failed]
Error: Cypress failed to start.

This is usually caused by a missing library or dependency.

The error below should indicate which dependency is missing.

https://on.cypress.io/required-dependencies

If you are using Docker, we provide containers with all required dependencies installed.
----------

Xlib:  extension "RANDR" missing on display ":99".
----------

Platform: linux (Debian - 8.11)
Cypress Version: 3.1.4
Error: Error: Cypress failed to start.

This is usually caused by a missing library or dependency.

The error below should indicate which dependency is missing.

https://on.cypress.io/required-dependencies

If you are using Docker, we provide containers with all required dependencies installed.
----------

Xlib:  extension "RANDR" missing on display ":99".
----------

Platform: linux (Debian - 8.11)
Cypress Version: 3.1.4
    at CatchSubscriber.selector (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/@nrwl/builders/src/cypress/cypress.builder.js:66:19)
    at CatchSubscriber.error (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/rxjs/internal/operators/catchError.js:48:31)
    at TakeSubscriber.Subscriber._error (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/rxjs/internal/Subscriber.js:93:26)
    at TakeSubscriber.Subscriber.error (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/rxjs/internal/Subscriber.js:73:18)
    at MergeMapSubscriber.OuterSubscriber.notifyError (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/rxjs/internal/OuterSubscriber.js:26:26)
    at InnerSubscriber._error (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/rxjs/internal/InnerSubscriber.js:31:21)
    at InnerSubscriber.Subscriber.error (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/rxjs/internal/Subscriber.js:73:18)
    at MapSubscriber.Subscriber._error (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/rxjs/internal/Subscriber.js:93:26)
    at MapSubscriber.Subscriber.error (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/rxjs/internal/Subscriber.js:73:18)
    at TapSubscriber._error (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/rxjs/internal/operators/tap.js:75:26)
    at TapSubscriber.Subscriber.error (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/rxjs/internal/Subscriber.js:73:18)
    at /builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/rxjs/internal/util/subscribeToPromise.js:10:43
    at tryCatcher (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/cypress/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/cypress/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/cypress/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/cypress/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/cypress/node_modules/bluebird/js/release/promise.js:689:18)
    at Async._drainQueue (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/cypress/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/cypress/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/builds/bgenbmdoe/HMI/app/client/hmi-client-workspace/node_modules/cypress/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)

@jennifer-shehane
Copy link
Member

Electron is set to be upgraded during our 4.0 release #2840

@jennifer-shehane
Copy link
Member

This looks to have been resolved in Electron 2.0.3 - we will be upgrading to Electron 2.0.18 #4001 as of the next release (3.3.0), so this is pending release.

@jennifer-shehane jennifer-shehane removed the stage: awaiting external fix A 3rd party bug in Cypress - awaiting release label Apr 26, 2019
@codeofsumit
Copy link

codeofsumit commented May 9, 2019

@jennifer-shehane this bug/problem is breaking most of our build pipelines currently and we do not want to release without the tests passing. We tried:
a) Downgrade Cypress to 3.1.4
b) To run our tests with unset NODE_OPTIONS && $(npm bin)/cypress run

Both did not work and cypress still fails to start. Can we do something else? Can you point me to another workaround until the next release is out? 🙏
Thanks in advance for any help

@jennifer-shehane
Copy link
Member

@codeofsumit Unsetting the NODE_OPTIONS should have worked. Downgrading Cypress would have no effect I believe. Could you check with the commands below? If this isn't working, please provide information on your versions/OS + the error you are seeing.

To see all environment variables currently set

MacOS / Linux

printenv

Windows

SET

To unset NODE_OPTIONS environment variable

MacOS / Linux

unset NODE_OPTIONS # this is not the same as export NODE_OPTIONS=

Windows

set NODE_OPTIONS=

@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 17, 2019

Released in 3.3.0.

@mooncowboy
Copy link

Happened to me in Windows 10 with 3.3.0. Solution was unsetting NODE_OPTIONS.

Cypress: 3.3.0
Browser: Electron 61 (headless)

@omelnik
Copy link

omelnik commented Jul 27, 2021

Just got the same error on the latest Cypress version. I tried to unset NODE_OPTIONS , but it didn't help much.
How do I solve this problem?

Update: After a few attempts of re-installing, I was able to launch successfully it.

It looks like this is your first time using Cypress: 8.0.0

Cypress failed to start.

This may be due to a missing library or dependency. https://on.cypress.io/required-dependencies

Please refer to the error below for more details.

----------

dyld: Library not loaded: @rpath/Electron Framework.framework/Electron Framework
Referenced from: /Users/user/Library/Caches/Cypress/8.0.0/Cypress.app/Contents/MacOS/Cypress
Reason: no suitable image found.  Did find:
/Users/user/Library/Caches/Cypress/8.0.0/Cypress.app/Contents/MacOS/../Frameworks/Electron Framework.framework/Electron Framework: file too short
/Users/user/Library/Caches/Cypress/8.0.0/Cypress.app/Contents/MacOS/../Frameworks/Electron Framework.framework/Electron Framework: stat() failed with errno=1

----------

Platform: darwin (19.6.0)
Cypress Version: 8.0.0
Node Version: v16.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli type: unexpected behavior User expected result, but got another
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants