Caching Playwright's Chromium dependency

I am trying to run some quick tests before the build, to stop it from deploying if site is broken.

I have Playwright in my npm dependencies, which is sufficient in GitHub Actions, but in Netlify build it asks that I install browser dependencies.

2:16:45 PM: > npx playwright install chromium && npm run server-test && npm run build
2:16:46 PM: Downloading Chromium 102.0.5005.40 (playwright build v1005)…
2:16:48 PM: |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■| 100% of 129.7 Mb
2:16:51 PM: Chromium 102.0.5005.40 (playwright build v1005) downloaded to /opt/buildhome/.cache/ms-playwright/chromium-1005

That works, however the download happens every time. There is some mixed information about .cache and from looking at image’s run-build-functions.sh it doesn’t seem to be cached at this time?

  1. Any recommendations how to handle it, does it need caching from Netlify perspective?
  2. Should I open this as an issue in image’s repository to suggest support?

I’ve tried third party netlify-plugin-cache, but it’s currently broken for me.

Site dnd.rarst.net

The problem is not with the plugin, but with Node version 18. Currently, we don’t recommend using Node > 16 for 2 reasons:

  1. AWS Lambda doesn’t support it yet, so it might create issues if you use Netlify Functions
  2. Our build system has some issues, especially with the plugin like the one you faced.