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

ENOTCONN error on Windows runs #5241

Closed
bkirova opened this issue Sep 30, 2019 · 16 comments · Fixed by #5293
Closed

ENOTCONN error on Windows runs #5241

bkirova opened this issue Sep 30, 2019 · 16 comments · Fixed by #5293

Comments

@bkirova
Copy link

bkirova commented Sep 30, 2019

Current behavior:

cypress throws error on Windows when launching more than one run as a separate process with execSync

C:\Users\fetest\Desktop\runners\loki\builds\bkDJzsb2\0\games\bridge\node_modules\cypress\lib\exec\spawn.js:175
          throw err;
          ^

Error: shutdown ENOTCONN
    at Socket._final (net.js:409:25)
    at callFinal (_stream_writable.js:627:10)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'ENOTCONN',
  code: 'ENOTCONN',
  syscall: 'shutdown'
}
child_process.js:660
    throw err;
    ^

Error: Command failed: "./node_modules/.bin/cypress" run --env layout="portrait-hd",lang="en",suite="dev",url="https://cdn.dopamine-gaming.com/review/games/bridge/dev" --spec cypress/integration/base_spec.js --headed
    at checkExecSyncError (child_process.js:621:11)
    at execSync (child_process.js:657:15)
    at execScript (C:\Users\fetest\Desktop\runners\loki\builds\bkDJzsb2\0\games\bridge\node_modules\automation\bin\test.js:81:5)
    at run (C:\Users\fetest\Desktop\runners\loki\builds\bkDJzsb2\0\games\bridge\node_modules\automation\bin\test.js:74:9)
    at C:\Users\fetest\Desktop\runners\loki\builds\bkDJzsb2\0\games\bridge\node_modules\automation\bin\test.js:50:42
    at Array.forEach (<anonymous>)
    at test (C:\Users\fetest\Desktop\runners\loki\builds\bkDJzsb2\0\games\bridge\node_modules\automation\bin\test.js:50:24)
    at Object.<anonymous> (C:\Users\fetest\Desktop\runners\loki\builds\bkDJzsb2\0\games\bridge\node_modules\automation\bin\test.js:84:1)
    at Module._compile (internal/modules/cjs/loader.js:945:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 996,
  stdout: null,
  stderr: null
}

Steps to reproduce:

Launch more than one time cypress run command with execSync

execSync('"./node_modules/.bin/cypress" run --spec cypress/integration/base_spec.js');
execSync('"./node_modules/.bin/cypress" run --spec cypress/integration/components_spec.js');

Versions

Cypress v3.4.1
Windows Version 10.0.18362
Node 12.11.0
npm 6.11.3

This issue is related to #1841

and is fixable by adding the erro code into already existing condition (line 169)

image

@Svish
Copy link

Svish commented Oct 3, 2019

Started getting this today too, and I have no knowledge of any execSync calls. Just running Cypress as I did before cypress run --project ./cypress... Tried to reboot in case there was anything "hanging", but that didn't seem to help anything either... 😕😒

C:\dev\projects\foobar\node_modules\cypress\lib\exec\spawn.js:175
          throw err;
          ^

Error: shutdown ENOTCONN
    at ReadStream.Socket._final (net.js:409:25)
    at callFinal (_stream_writable.js:627:10)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'ENOTCONN',
  code: 'ENOTCONN',
  syscall: 'shutdown'
}
Error: Command failed with exit code 2 (ENOENT): npm run test:cypress:run
spawn npm run test:cypress:run ENOENT
    at notFoundError (C:\dev\projects\foobar\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\dev\projects\foobar\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\dev\projects\foobar\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) {
  errno: 'ENOENT',
  syscall: 'spawn npm run test:cypress:run',
  path: 'npm run test:cypress:run',
  spawnargs: [],
  command: 'npm run test:cypress:run',
  exitCode: 2,
  exitCodeName: 'ENOENT',
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false,
  signal: undefined
}

@flotwig
Copy link
Contributor

flotwig commented Oct 3, 2019

Hey @bkirova @Svish, thanks for making us aware of this.

@Svish Are you also opening up 2 Cypress instances? Or just one?

@bkirova If you'd like to, you can open a pull request that fixes that offending line of code, since you've already found what's going wrong. We'd be happy to merge a fix.

@Svish
Copy link

Svish commented Oct 3, 2019

As I wrote, I don't know anything about execSync or multiple instances. I'm just running the Cypress test runner as I've done since I first started using Cypress months ago. Worked fine before. 😕

@flotwig
Copy link
Contributor

flotwig commented Oct 3, 2019

Super strange. Can you provide DEBUG logs from the crash? Since you're on Windows, you can install cross-env so you can pass environment variables:

npm i -g cross-env
cross-env DEBUG=cypress:* cypress run --project ./cypress

Also, did this only start happening in 3.4.1, or has 3.4.1 been working fine and then this started to happen?

@jbolda
Copy link

jbolda commented Oct 3, 2019

As another data point, I am only seeing this on windows with npm and node 12. I don't think I was testing this combination prior to 3.4.1 though so I can't comment on your question. I have this error in a Github Actions CI run (hopefully you have access to the beta), and opened a PR to trigger a run with DEBUG enabled.

@idxrx
Copy link

idxrx commented Oct 4, 2019

I also got this error when I updated from node-v12.9.1-x64 to node-v12.11.1-x64. To solve this issue for now, go back to 12.9.1

@idxrx
Copy link

idxrx commented Oct 4, 2019

To be a little more precise: node-v12.10 is also working, but version node-v12.11.0 not.

@flotwig
Copy link
Contributor

flotwig commented Oct 4, 2019

Here's the 12.11.0 changelog. I was unable to find any change that clearly causes this. I'll open a PR with @bkirova's patch so this can be fixed in the next release.

@Svish
Copy link

Svish commented Oct 4, 2019

Haven't been at the office today, so haven't been able to confirm, but I did upgrade Node to latest version recently too, so sounds like that could maybe be the issue then. 🤔

@flotwig flotwig self-assigned this Oct 4, 2019
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Oct 4, 2019
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Oct 7, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 7, 2019

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

@cypress-io cypress-io deleted a comment from cypress-bot bot Oct 7, 2019
@Svish
Copy link

Svish commented Oct 16, 2019

Finally back at work (that was one resilient cold virus... 👀), and can confirm that if I downgrade node to 12.10.0 I get no error. If I upgrade to next version, 12.11.0, I get the error again. Also getting the error in the latest version, 12.12.0.

I see the fix in #5293 simply ignores the error code, but is that an actual fix? Maybe would be good to also figure out why this error suddenly is happening now, rather than just ignoring it? Maybe there's a bigger issue in Cypress that should actually be fixed? Some pipes that aren't closed properly? Data that's not sent/received properly? Something?

@flotwig
Copy link
Contributor

flotwig commented Oct 16, 2019

Here's my understanding:

process.stdin from the CLI is piped the stdin of the Electron process Cypress runs in. Then, when the underlying Electron process exits, the process.stdin stream in the CLI throws an ENOTCONN error (only in Windows, only in Node 12.11.0+). Sometimes, it throws an EPIPE error instead, which was handled previously to this issue in #1841

There's very little documentation about the meaning of these error codes in Node.js, but I found some info on the generic POSIX meaning here: https://stackoverflow.com/a/902964/3474615

EPIPE and ENOTCONN both basically mean that the pipe is no longer connected at both ends. We handle the exit of the Cypress subprocess by listening for the close event: https://github.com/cypress-io/cypress/pull/5293/files#diff-ff9015f47ff83939a603dd46c4fb45d1R140

...so I think it is unlikely that adding ENOTCONN to the list of suppressed errors will cause any bad behavior - Cypress will still exit normally when the underlying stream exits, it's not causing any data to be lost (it's on stdin, which is unused in Cypress), etc.

@dugajean
Copy link

Any updates on this? Just updated to Node's new LTS version 12.13 and I started getting this error now.

@flotwig
Copy link
Contributor

flotwig commented Oct 21, 2019

@dugajean The issue has been fixed in the develop branch and it will come out with the next release.

@dugajean
Copy link

Thanks a lot for the prompt answer @flotwig

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 23, 2019

Released in 3.5.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.