Puppeteer cluster sometimes cannot start in k8s

1/15/2020

I'm using puppeteer with puppeteer-cluster, this is deployed on k8s and everything works great. The only problem I'm having is that sometimes the pod won't start, and throws this exception:

(node:24) UnhandledPromiseRejectionWarning: Error: Unable to launch browser, error message: read ECONNRESET
    at Cluster.<anonymous> (/app/node_modules/puppeteer-cluster/dist/Cluster.js:107:23)
    at Generator.throw (<anonymous>)
    at rejected (/app/node_modules/puppeteer-cluster/dist/Cluster.js:6:65)
    at process._tickCallback (internal/process/next_tick.js:68:7)

followed by:

(node:24) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

and:

(node:24) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This doesn't affect me functionally considerably, as k8s just creates a new pod (which works fine), but I'd like to understand what happens, and if I can fix it.

Cluster initialization code:

    const cluster = await Cluster.launch({
      concurrency: Cluster.CONCURRENCY_CONTEXT,
      maxConcurrency: Constants.CONFIG.URL_CONCURRENCY,
      retryLimit: Constants.CONFIG.CLUSTER_INTERNAL_RETRIES,
      timeout: Constants.CONFIG.MAX_TIMEOUT
      puppeteerOptions: { ignoreHTTPSErrors: true, args: ["--no-sandbox"] }
    });

versions:

    "puppeteer": "^2.0.0",
    "puppeteer-cluster": "^0.18.0",
-- orirab
kubernetes
node.js
puppeteer
puppeteer-cluster

0 Answers