node-html-to-image icon indicating copy to clipboard operation
node-html-to-image copied to clipboard

Serverless Run: custom Puppeteer

Open davodm opened this issue 1 year ago • 2 comments

Hi, I used the function on a lambda function with puppeteer-core and @sparticuz/chromium based on your document.

But the error I'm facing is:

Unable to launch browser, error message: spawn ETXTBSY at Cluster. (/var/task/node_modules/puppeteer-cluster/dist/Cluster.js:119:23)

Which comes from node-html-to-image package dependencies.

Here are the versions I'm using: "puppeteer-core": 21.3.7 "@sparticuz/chromium": 117.0

Here is the way I'm using the function:

// AWS Config
    let AWSconf = {};
    if (!isOffline() && chromium) {
      AWSconf = {
        puppeteer: puppeteerCore,
        puppeteerArgs: {
          args: chromium.args,
          executablePath: await chromium.executablePath(),
          headless: chromium.headless,
          ignoreHTTPSErrors: true,
          defaultViewport: chromium.defaultViewport,
          args: [
            ...chromium.args,
            "--hide-scrollbars",
            "--disable-web-security",
            '--no-sandbox'
          ],
        },
      };
    }
    // Generate the image
    await nodeHtmlToImage({
      html: renderedHtml,
      content: data, // It already using Handlebars
      output: $outputPath + outputFileName,
      transparent: true,
      ...AWSconf,
    });

davodm avatar Oct 11 '23 14:10 davodm