How to fix puppeteer intermittently failing when downloading chrome-headless-shell on CI

185 Views Asked by At

I'm working with a large monorepo which uses puppeteer for testing. Installing dependencies works fine locally, but puppeteer fails to download intermittently on the CI (AWS codepipeline/codeBuild). The failure rate is around 50%.

The error from the logs is;

... npm ERR! path /codebuild/output/src1712585824/src/common/temp/pnpm-store/v3/tmp/_tmp_283_05a92cf37702a3f0d9171146248ad439/node_modules/puppeteer
... npm ERR! command failed
... npm ERR! command sh -c -- node install.mjs
... npm ERR! Error: ERROR: Failed to set up chrome-headless-shell v121.0.6167.85! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
... npm ERR!     at file:///codebuild/output/src1712585824/src/common/temp/pnpm-store/v3/tmp/_tmp_283_05a92cf37702a3f0d9171146248ad439/node_modules/puppeteer/lib/esm/puppeteer/node/install.js:81:27
... npm ERR!     at async Promise.all (index 1)
... npm ERR!     at async downloadBrowser (file:///codebuild/output/src1712585824/src/common/temp/pnpm-store/v3/tmp/_tmp_283_05a92cf37702a3f0d9171146248ad439/node_modules/puppeteer/lib/esm/puppeteer/node/install.js:87:9) {
... npm ERR!   [cause]: Error: unexpected end of file
... npm ERR!       at Zlib.zlibOnError [as onerror] (node:zlib:189:17) {
... npm ERR!     errno: -5,
... npm ERR!     code: 'Z_BUF_ERROR'
... npm ERR!   }
... npm ERR! }

Has anyone seen this before? Does anyone have any thoughts on the cause/solution?

I have tried to install dependencies locally, which works reliably.

When dependencies are installed on the CI puppeteer fails intermittently. I would expect it to succeed reliably too.

Puppeteer version ^21.5.0 (21.9.0)

Thanks

0

There are 0 best solutions below