question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple zombie processes when running Cypress inside the Docker with Node

See original GitHub issue

Current behavior

When running Cypress tests in an infinite loop inside a docker container and starting the test script with node cypress.js, we can see a huge amount of zombie (<defunct>) processes. When starting the same cypress-test.js file inside the docker container by using a shell script - all child processes are killed correctly, so no zombies are left. Due to this bug, it is impossible to run cypress tests using ‘pm2’ or ‘node’ inside a docker container. At one point all processes just stop, because no free PID is left, so no new process can be started.

Tested with Cypress Version: 7.7.0, 9.6.1

Desired behavior

No <defunct> zombie processes should appear, when running cypress tests synchronously inside a docker container by using ENTRYPOINT [ "node", "./cypress-test.js" ]

Test code to reproduce

Dockerfile:

FROM cypress/browsers:node14.16.0-chrome90-ff88

RUN mkdir /opt/prj/
WORKDIR /opt/prj/
COPY package.json package-lock.json *node_modules /opt/prj/

RUN npm install
RUN $(npm bin)/cypress verify

COPY . /opt/prj/
ENTRYPOINT [ "node", "./cypress-test.js" ]

cypress-test.js:

const cypress = require('cypress');
const TEST_FOLDER_PATH = process.cwd() + '/cypress/integration/test/';

(async () => {
    while (true) {
        const result = await cypress.run({
            spec: TEST_FOLDER_PATH + 'test.spec.js',
            video: false
        });
    }
})();

/cypress/integration/test/test.spec.js

describe('Test', () => {
    it('should be true', () => {
        expect(1).to.equal(1);
    });
});

cypress.json

{
  "pluginsFile": "cypress/plugins/index.js",
  "retries": {
    "runMode": 1,
    "openMode": 0
  },
  "defaultCommandTimeout": 15000,
  "video": false,
  "videoCompression": false,
  "videoUploadOnPasses": false,
  "viewportWidth": 1280,
  "viewportHeight": 720
}

Start docker:

> docker build . -t cypress
> docker run cypress

Look up the name of the running docker container and execute:

> docker exec -it <container_name> bash
> ps aux
Bildschirmfoto 2022-05-11 um 23 18 57

___________________ EXAMPLE WITH NO ZOMBIES____________________________________________ When replacing the ENTRYPOINT in the Dockerfile with:

RUN ["chmod", "+x", "/opt/prj/commands.sh"]
ENTRYPOINT [ "./commands.sh" ]

commands.sh

#!/bin/bash
node cypress-tests.js

NO Zombies

Bildschirmfoto 2022-05-11 um 23 26 43

Cypress Version

7.7.0, 9.6.1

Other

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
BlueWindscommented, Jun 30, 2022

@daria-graf - I stand corrected, you are absolutely right now that I look back at this. I wasn’t reading your sample script correctly, and thought it was leaving the zombies Cypress processes itself, which is not the case.

With that said, I’m not sure this is going to be easy to prioritize for the team. I’m reopening, but doubt we’ll have time to take a look - if you or another contributor wants to take a crack at auditing how we open processes and properly waiting for them, feel free to ping me on a PR and I’ll take a look.

–init / tini remains at least a valid workaround though.

1reaction
mjhenkescommented, May 16, 2022

Based on the article you included, it seems we may have two solutions:

  1. Check to make sure processes are being properly terminated in cypress.
  2. Add the mentioned script in the article to clean up zombie processes, This would probably be the quicker fix.
Read more comments on GitHub >

github_iconTop Results From Across the Web

zombies inside of docker - node.js
This application runs a headless-chrome instance. All work well, but if i kill chrome-instance, and check runned processes list, i will see 2( ......
Read more >
Docker and the PID 1 zombie reaping problem - Phusion Blog
Well, we see that a lot of people run only one process in their container, and they think that when they run this...
Read more >
Zombie Meteor process eating a whole core (>100% CPU)
Steps to reproduce are as simple as running meteor in the project, and then killing it. While running everything is ok. I see...
Read more >
Zombie processes when running in Docker
The issue is that Exhibitor is using the zkServer.sh script to run the Zookeeper, which in turn runs it with nohup, causing it...
Read more >
RHSA-2020:5633 - Security Advisory - Red Hat 客户门户网站
BZ - 1878772 - On the nodes there are up to 547 zombie processes ... to two infra nodes simultaneously - keepalived process...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found