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

ReLaXed spawns defunct chrome processes #137

Open
jonathanasquier opened this issue Jul 1, 2019 · 3 comments
Open

ReLaXed spawns defunct chrome processes #137

jonathanasquier opened this issue Jul 1, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@jonathanasquier
Copy link

jonathanasquier commented Jul 1, 2019

Hi,
I'm using relaxed in nodeJS with a promise interface by spawning a relaxed child process.
I recently crashed my production server with 32k+ defunct chrome processes.

I tried to tree-kill my own child process, browser.close() and tree-kill the process.pid in the program.buildOnce condition, but still it seems 4-5 chrome process are launched.

root     23736  0.5  0.0      0     0 ?        Z    19:57   0:00 [chrome] <defunct>
root     23748  0.8  0.0      0     0 ?        Z    19:57   0:00 [chrome] <defunct>
root     23752  0.3  0.0      0     0 ?        Z    19:57   0:00 [chrome] <defunct>
root     23765  6.0  0.0      0     0 ?        Z    19:57   0:00 [chrome] <defunct>

Right now the only way I've got to prevent my server from crashing is restarting my docker container every once and a while, which destroys the chrome processes (I'm the one who wrote the dockerfile that is referenced in ReLaXed's README :) )

I have no experience with working directly with puppeteer and would be delighted with a little help!

Thanks!

PS: please don't let me use wkhtmltopdf again!!

@DanielRuf
Copy link
Contributor

Hi @jonathanasquier,

the launch and newPage() commands create new tabs and spawn the processes in most cases.

https://github.com/RelaxedJS/ReLaXed/blob/master/src/index.js#L142-L143

close will destroy the instances, see https://github.com/DanielRuf/website-checks/blob/master/index.js#L56, this can be used for page (tab) and browser instances.

Currently I see no usage of close.
https://github.com/RelaxedJS/ReLaXed/search?q=close&unscoped_q=close

Can you try to add browser.close(); and / or relaxedGlobals.puppeteerPage.close(); to https://github.com/RelaxedJS/ReLaXed/blob/master/src/index.js#L152?

@DanielRuf DanielRuf added the bug Something isn't working label Jul 1, 2019
@jonathanasquier
Copy link
Author

I tried, with no success :(
My use case being with docker i think I got this problem
And I ended up using config I actually used in my relaxed dockerfile, but not in my own service 🤦‍♂️

ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init
# ...
ENTRYPOINT ["dumb-init", "myservice"]

which prevent ending up with defunct chrome processes

If you believe this issue/solution is out of scope of the ReLaXed project, feel free to close it :)

@DanielRuf
Copy link
Contributor

Right, sounds like this issue. But I'm not completely sure if we should still properly close the browser instances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants