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

Help needed: Pupeteer.launch hangs inside Docker image #339

Open
randomsnowflake opened this issue Oct 27, 2024 · 0 comments
Open

Help needed: Pupeteer.launch hangs inside Docker image #339

randomsnowflake opened this issue Oct 27, 2024 · 0 comments

Comments

@randomsnowflake
Copy link

I have an issue getting a headless Chrome browser to run in my Ruby on Rails app deployed via Docker. It times out on all requests when started from the web server, but it works perfectly when launched from the Rails console or in dev mode.

I want to fetch a remote URL and extract its content.

I have set up a demo repository, to reproduce the issue: https://github.com/randomsnowflake/puppeteertest

The relevant changes are:

This is pretty standard code that used to work on another system.

To reproduce the timeout:

git clone https://github.com/randomsnowflake/puppeteertest.gitt
cd puppeteertest
docker compose build
docker compose up

# in a webbrowser: http://localhost:3000/test/test
# this request will timeout
# it will hang in the "Puppeteer.launch" call in the Puptest model
# setting CHROME_PATH does not seem to have an effect

To see it working:

Using dev mode

bin/dev # this starts the local rails dev srver
# in a webbrowser: http://localhost:3000/test/test
# this will output some random webpages HTML content
# note: it also works in local production mode

Using docker and rails console

# Note: will not work on M1 macs because of rosetta error, it does work in Linux
docker exec -it <CONTAINER_ID> bin/rails c

issue(prod)> x = Puptest.new.fetch_content("https://www.google.com")
# this will load the content of the remote page, as expected

So you see, the puppeteer code works, but only in dev/production mode and via the rails console in Docker. Inside the docker webserver it fails. In one Docker log I see several [1] ! reaped unknown child process pid=1805 status=pid 1805 exit 0 errors in the log, most likely from puma.

Thanks for pointing me in the right direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant