cypress: ENOTCONN error on Windows runs

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 https://github.com/cypress-io/cypress/issues/1841

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

image

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 16 (7 by maintainers)

Most upvoted comments

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. 😕

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
}

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

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.

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. 🤔