api-screenshot icon indicating copy to clipboard operation
api-screenshot copied to clipboard

Enable puppeteer and Chromium to work with latest versions of Node.

Open LewisDaleUK opened this issue 2 years ago • 3 comments

Update puppeteer-core and replace chrome-aws-lambda with @sparticuz/chromium

The current code will only work with Node 12, meaning it can't be deployed out of the box as Netlify uses Node 16.

The chrome-aws-lambda package hasn't been maintained in over a year, https://github.com/sparticuz/chromium is an alternative that provides the same functionality.

This is now able to be auto-deployed by Netlify and run out-of-the-box again

Sources:

  • https://answers.netlify.com/t/netlify-cli-dropping-support-for-node-js-version-12/75130

LewisDaleUK avatar Nov 04 '22 10:11 LewisDaleUK

Deploy Preview for eleventy-api-screenshot failed.

Name Link
Latest commit 804ed9359288a840e2a01efd258f0f4111b31f74
Latest deploy log https://app.netlify.com/sites/eleventy-api-screenshot/deploys/6364ebbfe9e4db00088a0859

netlify[bot] avatar Nov 04 '22 10:11 netlify[bot]

Ah okay, looks like the Chromium package includes the Chromium binary and means the bundle is 60mb. Interestingly, it deploys without issue for me - could be because my deploy is using Ubuntu Focal, whereas yours is using Xenial

LewisDaleUK avatar Nov 04 '22 10:11 LewisDaleUK

Trying the changes in this test on Netlify and it just times out on each request.

image

homotechsual avatar May 12 '23 14:05 homotechsual

Thank you @LewisDaleUK! I ended up using these code changes in the v1-vercel branch and api-screenshot which is the primary branch moving forward. Happy to merge them to v1-netlify too now.

zachleat avatar Jul 18 '24 00:07 zachleat