microlinkhq / browserless

The headless Chrome/Chromium driver on top of Puppeteer.
https://browserless.js.org
MIT License
1.63k stars 81 forks source link

TimeoutError: Timed out after 60000 ms while waiting for the WS endpoint URL to appear in stdout! #518

Closed paul-bell closed 1 year ago

paul-bell commented 1 year ago

Prerequisites

Subject of the issue

TimeoutError: Timed out after 60000 ms while waiting for the WS endpoint URL to appear in stdout!
    at ChromeLauncher.launch (/data/hermes/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:149:23) {
  attemptNumber: 1,
  retriesLeft: 0
}

Steps to reproduce

I suspect that my program is doing something wrong. I believe the relevant parts of that program include:

browser = createBrowser({
    ignoreHTTPSErrors: true, 
    executablePath: CHROME_browserPath,
    timeout: 60000,
}); 

CHROME_browserPath maps to /usr/local/bin/chrome-linux64/chrome:

bash-4.2$ ls -lt /usr/local/bin/chrome-linux64/chrome
-rwxr-xr-x 1 root root 228965416 Sep 14 22:51 /usr/local/bin/chrome-linux64/chrome

bash-4.2$ /usr/local/bin/chrome-linux64/chrome --version
Google Chrome for Testing 117.0.5938.88

I am running browserless.js version 10.1.2 and Puppeteer 21.3.1. I believe that they are happy with the version of Chrome shown above. Please note that despite this claim on the Puppeteer NPM page:

When you install Puppeteer, it automatically downloads a recent version of Chrome for Testing (~170MB macOS, ~282MB Linux, ~280MB Windows) that is guaranteed to work with Puppeteer. The browser is downloaded to the $HOME/.cache/puppeteer folder by default (starting with Puppeteer v19.0.0).

There is no evidence of any such "automatic download," i.e., Chrome exists only in the aforementioned executablePath. But at least for now, this issue is not germane.

The program runs Dockerized on a CentOS 7 Linux. Note also that 18 months ago I was able to run Puppeteer "raw", i.e., older versions that used chromedriver, in the same Linux environment.

Expected behaviour

The browser is found and instantiated.

Actual behaviour

The timeout error shown above

Thanks for your guidance on this.

Kikobeats commented 1 year ago

Ensure your package.json looks like this:

{
  "dependencies": {
    "browserless": "latest",
    "puppeteer": "latest"
  },
  "scripts": {
    "postinstall": "node node_modules/puppeteer/install.js"
  }
}

Then, npm install, and that's all. You don't need to specify the binary path 🙂

paul-bell commented 1 year ago

Thank you very much. I will be testing today.

paul-bell commented 1 year ago

So...the beat goes on.

I got the install script to work, i.e., Chrome is now installed. But, given that we're dealing with a Docker container created by a "docker build" command, its location is different. It landed in this directory:

/efs/tmp/node/home/.cache/puppeteer/chrome/linux-117.0.5938.92/chrome-linux64

I naively assumed that, regardless of where the Puppeteer script installed Chrome, it would know to find it there. Wrong again: first experiments showed Puppeteer complaining that he could not find the Chrome executable.

Thus I again asserted the executablePath property to the browser constructor. The "not found" complaint went away, but the original "Timed out after 60000 ms" returned.

At this point, I am at a real loss as to how to proceed. In the hope that browserless+chrome is faster than Firefox+Selenium, I am eager to make it work. (I can say that browserless+chrome is far simpler to use than FF+Selenium).

I am grateful for your ongoing help with this.

Thanks again.