Cypress: dest.end error crash during run exit on GitLab CI / Windows

Created on 20 Jul 2018  Β·  38Comments  Β·  Source: cypress-io/cypress

Cypress >=v3.0.0 on GitLabCI

Current behavior:

Any version >= v3.0.0 of the Cypress is failing to run on the GitLab's CI. The following error is being thrown exactly before cypress is exiting:

====================================================================================================

(Run Finished)


Spec Tests Passing Failing Pending Skipped 
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ βœ” HomePage\Home_Page_Quick_Lookup.js 00:05 1 1 - - - β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
All specs passed! 00:05 1 1 - - - 

cypress:server:cypress about to exit with code 0 +159ms
_stream_readable.js:595
dest.end();
^

TypeError: dest.end is not a function
at Socket.onend (_stream_readable.js:595:10)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1055:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
ERROR: Job failed: exit status 1

Desired behavior:

We expect the cypress to return the (All Done) message as Cypress v2.1.0 does with no error.

Steps to reproduce:

I have an issue with running cypress on the GitLab’s CI provider. I want to confirm whether this is a configuration issue, an incompatibility issue or a cypress bug.

I have installed cypress using the yarn command yarn add cypress. This will install me the latest version of cypress, namely v3.0.2.

_[path-to-root-of-solution]/cypress.json_

{
  "projectId": "……",
  "baseUrl": "…. "
}

_[path-to-root-of-solution]/cypress/integration/HomePage/Home_Page_Quick_Lookup.js_

describe('Home Page Test - Find Button', function () {

  before(function() {
    // navigate to home page (baseUrl)
    cy.visit('')

  })

  it('Check the button is on the page', function () {
    cy.get('[data-test=button-test-base]').should('exist')
  })
})

_[path-to-root-of-solution]/gitlab-ci.yml_

# … set path… 

stages:
  - test

run_test_suite:
  stage: test
  script:
    - call yarn add cypress
    - npx cypress run 

# .. end of file …

When I start the cypress using the command npx cypress run

Versions

β€’ Windows Server 2012 R2
β€’ Node: 8.9.4
β€’ npm: 5.6.0
β€’ Gitlab CI Runner: 9.5.0

Comments

I have searched to see if there are other who experienced this issue, but it seems that no one have. (or at least they didn’t bother in reporting the issue and/or sharing their solution).
The https://github.com/cypress-io/cypress/issues/1841 is the only issue that is a bit relevant to this problem in the sense that the pipeline fails when cypress is about to exit.

We have tried to use other versions of cypress:
β–Ί v3.0.2, v3.0.1, v3.0.0 – the above error is being generated
β–Ί v2.1.0 – no error is being generated

gitlab windows bug

Most helpful comment

Hello Jeniffer, I need you

All 38 comments

Not working in v3.0.3 either

I have exactly the same issue! I really would like a fix and start using this in my CI nightly build.

Same issue here with buddy.works and my local machine (Mac).

I have the same problem, runs fine from terminal on my laptop running Ubuntu but exits with that error while running from command prompt on a Windows Server 2016 Jenkins node.

I have the same issue.

_stream_readable.js:511
    dest.end();
         ^

TypeError: dest.end is not a function
    at Socket.onend (_stream_readable.js:511:10)
    at Socket.g (events.js:292:16)
    at emitNone (events.js:91:20)
    at Socket.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

We have the same issue too.

  • Windows Server 2012 R2
  • Node: 8.2.1
  • npm: 6.2.0
  • Gitlab CI Runner: 11.2.0

this is blocking for us. anyone managed to workaround this issue?

any news or eta on this issue?

We have an example of the cypress-example-kitchensink running and passing within Gitlab CI, so it appears that runs on Gitlab CI do not all fail.

If someone can give a reproducible example - or isolate exactly what is different from their run and example - that will help us track down where the exit status is coming from.

Also, you can get more in depth run logs by setting DEBUG in the command line.

I have upgraded both my gitlab to version v11.4.2 and the cypress to version v3.1.2 and I am still getting the error.

The project is quite simple:

  1. I have downloaded one CMS from the internet, namely DNN Platform v8.2.0
  2. I have added a button to the homepage
  3. I have wrote a small cypress script to test if the button exists on the page.

i.e. the single fixture within the cypress

describe('Home Page Quick Lookup', function () {
  before(function() {
    cy.visit('')
  })

  beforeEach(function () {
    // Cypress normally clears out cookies between each test. This line keeps dnn's anti-forgery
    // validation token so that calls to the api still work between tests
    Cypress.Cookies.preserveOnce('__RequestVerificationToken')
  })

  it('Checks the elements are on the page', function () {
    cy.get('[data-test=quick-lookup-base]').should('exist')
  })

})
  1. I have run it locally with cypress and no error is being generated.
  2. I have added it the GitLab CI and it is failing. I have added the CI to run with the DEBUG flag.
    > i.e. [.gitlab-ci.yml]
- set DEBUG=cypress:*
- call yarn add [email protected]
- npx cypress run --record --key %CypressKey_Test% --config baseUrl=%TestDeploy_TargetUri%

I have attached the log file (~1030 lines). cypress-gitlab-ci--v312.log. However, I have replaced some of the content (urls, username, external apis) due to some contract limitations/liabilities. However, the lines 66 and 1017 from the debug are the same: cypress:server:cypress about to exit with code 0 . Why would cypress mention twice that is about to exit ?

Hello there. Any update on this issue?

Same thing here for 3.1.4. Behavior is reproduced on windows 10, but not mac.

The failure is being thrown from the readable-stream package on this line of code. This is included in core Node as stream

Our Node version:

  • 8.2.1

Your original comment seems to indicate this was introduced in version 3.0.0 of Cypress which was released on May 29, 2018.

This file had commits made to it May 21, 2018 - it is one of 3 files that require Node stream.

I suspect that this error was introduced in the commit above and only happens on Windows in GitLab.

I've seen some open issues concerning TTY in GitLab? That's a wild guess that it's related though.

I should note that this issue happens on my local machine. We are using TFS and not GitLab for our CI, but it's windows either way.

Messing around my setup some more, it turns out that we were using a grunt-exec task to execute our integration tests. When running cypress directly, we do not see this behavior. Switching this task out with grunt-shell is a successful workaround for us.

i have same trouble.

Same here

Same with me. Been waiting for this to be fixed.

Same problem here... Fix please!

Hello Jeniffer, I need you

Any update on this issue? I have the same issue too!

This issue seems to be related: https://github.com/cypress-io/cypress/issues/3863

Using git bash on windows with pre-commit causes this error but running cypress through git bash normally works which is odd

Can y'all confirm if you are using precommit hooks?

This also explains some possible fixes: https://github.com/typicode/husky/issues/459#issuecomment-485568858

I don't use

@jennifer-shehane I tried what you suggested above, but with no result. Even using Node 8.16, the error happens.

@PCStefan Did you find any solution to the problem? I've tried other versions of Node ^ 8.0.0 and Cypress ^ 3.0.0, but it does not work, only Cypress version 2.1.0 works correctly with git runner in Windows.

I found a workaround to the problem, using "git bash" as the default "shell" for Git Lab Runner.

1. Change windows registry "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servicesgitlab-runner" so it looks like this:

C:\Program Files\Git\bin\bash.exe -c "/c/gitlab/gitlab-runner.exe run --working-directory /c/gitlab --config /c/gitlab/config.toml --service gitlab-runner"

2. Set the "builds_dir" path in the runner configuration file, config.toml, using default bash syntax. Example:

builds_dir = "/C/GitLab-Runner/builds/CI"

3. Also in the config.toml file, set bash (git bash) as the default shell.

executor = "shell"
shell = "bash"

Running into this consistently on Windows CircleCI (Node 12.0.0 I believe). Relevant part of the last logs before exitting and crashing

  Recorded Run: https://dashboard.cypress.io/#/projects/6p53jw/runs/32463                              

STREAM 6056: dest.write true
STREAM 6056: maybeReadMore read 0
STREAM 6056: read 0
STREAM 6056: need readable true
STREAM 6056: length less than watermark true
STREAM 6056: do read
NET 6056: _read
STREAM 6056: readableAddChunk <Buffer 20 20 1b 5b 33 38 3b 35 3b 32 30 31 3b 31 6d 63 79 70 72 65 73 73 3a 73 65 72 76 65 72 3a 63 79 70 72 65 73 73 20 1b 5b 30 6d 61 62 6f 75 74 20 74 6f ... 39 more bytes>
STREAM 6056: ondata
  cypress:server:cypress about to exit with code 0 +40s
STREAM 6056: dest.write true
STREAM 6056: maybeReadMore read 0
STREAM 6056: read 0
STREAM 6056: need readable true
STREAM 6056: length less than watermark true
STREAM 6056: do read
NET 6056: _read
STREAM 6056: readableAddChunk null
STREAM 6056: onEofChunk
STREAM 6056: emitReadable_ false 0 true
STREAM 6056: flow true
STREAM 6056: read undefined
STREAM 6056: endReadable false
STREAM 6056: read 0
STREAM 6056: endReadable false
STREAM 6056: endReadableNT false 0
NET 6056: destroy
NET 6056: close
NET 6056: close handle
STREAM 6056: onend
_stream_readable.js:658
    dest.end();
         ^

TypeError: dest.end is not a function
    at Socket.onend (_stream_readable.js:658:10)
    at Object.onceWrapper (events.js:284:20)
    at Socket.emit (events.js:201:15)
    at endReadableNT (_stream_readable.js:1130:12)
    at processTicksAndRejections (internal/process/task_queues.js:83:17)
MODULE 5892: Module._load REQUEST os parent: C:\ProgramData\nvm\v12.0.0\node_modules\npm\lib\utils\error-handler.js
MODULE 5892: load native module os
npm ERR! code ELIFECYCLE

Hi, any update/fix on this issue?
I am using:

 "husky": {
      "version": "2.7.0",
}

"cypress": {
      "version": "3.4.1",
}

Facing the same exact issue.

There is a pull request that fixes this issue but it hasn't been merged and released yet. You can also apply a patch yourself following https://docs.cypress.io/guides/guides/debugging.html#Patch-Cypress

Awesome. Thank you so much! πŸ˜ƒ

was this fixed yet in an official release?

Any update on this issue? I have the same issue too!

@bahmutov Thanks for the patch! After applying it, we didn't encounter dest.end error while running Cypress E2E tests on GitLab's CI / Windows.

From the other side, after applying a patch, we faced with a new problem with duplicate log entries on test execution. Please see the screenshot of a Job below:

CIGitLab

Is there a way to avoid duplicate log entries?

Thanks.

Wow this is a great catch, that’s why I love beta testing fixes before releases, nothing like noticing thing like this

Sent from my iPhone

On Sep 17, 2019, at 07:55, jelsav notifications@github.com wrote:

@bahmutov Thanks for the patch! After applying it, we didn't encounter dest.end error while running Cypress E2E tests on GitLab's CI / Windows.

From the other side, after applying a patch, we faced with a new problem with duplicate log entries on test execution. Please see the screenshot of Job below:

Is there a way to avoid duplicate log entries?

Thanks.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Yup, I have used the patch and I can confirm this side-effect.

@nweiser1 @AliceShi789654 Try using the patch. It's not hard to do πŸ™‚

@jelsav did you apply the patch correctly - you need to remove existing pipe lines. I have tried the patch in https://circleci.com/gh/cypress-io/cypress-test-tiny/4442 and everything looks ok

Screen Shot 2019-09-19 at 10 27 54 AM

here is my patch file patches/cypress+3.4.1.patch

diff --git a/node_modules/cypress/lib/exec/spawn.js b/node_modules/cypress/lib/exec/spawn.js
index ed13727..7748f19 100644
--- a/node_modules/cypress/lib/exec/spawn.js
+++ b/node_modules/cypress/lib/exec/spawn.js
@@ -138,8 +138,15 @@ module.exports = {
         child.on('close', resolve);
         child.on('error', reject);

-        child.stdin && child.stdin.pipe(process.stdin);
-        child.stdout && child.stdout.pipe(process.stdout);
+        if (child.stdin) {
+          debug('piping process STDIN into child STDIN')
+          process.stdin.pipe(child.stdin)
+        }
+
+        if (child.stdout) {
+          debug('piping child STDOUT to process STDOUT')
+          child.stdout.pipe(process.stdout)
+        }

         // if this is defined then we are manually piping for linux
         // to filter out the garbage

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

@bahmutov

A few days ago, we applied a patch that we downloaded from here: https://github.com/CodingGardenCommunity/app-frontend/blob/08dbf63b59631faef0a9945cf8b20b40b138f2fc/patches/cypress%2B3.4.1.patch

It fixed dest.end error but we found a new issue with duplicated log entries.

Today, we applied a patch file you provided in your last comment. We no longer have problems with dest.end error or duplicated log entries.

Cypress version: 3.4.1

Thank you very much!

Released in 3.5.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

weskor picture weskor  Β·  3Comments

EirikBirkeland picture EirikBirkeland  Β·  3Comments

carloscheddar picture carloscheddar  Β·  3Comments

brian-mann picture brian-mann  Β·  3Comments

scottcrowe picture scottcrowe  Β·  3Comments