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
}
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');
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)

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
}
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.
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. 馃槙
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?
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.
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
To be a little more precise: node-v12.10 is also working, but version node-v12.11.0 not.
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.
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. 馃
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.
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?
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.
Any updates on this? Just updated to Node's new LTS version 12.13 and I started getting this error now.
@dugajean The issue has been fixed in the develop branch and it will come out with the next release.
Thanks a lot for the prompt answer @flotwig
Released in 3.5.0.
Most helpful comment
As I wrote, I don't know anything about
execSyncor 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. 馃槙