Using puppeteer in Netlify build

I’m building with puppeteer (I scrape a site for the latest content, which is then integrated into the build). It was working a few months ago, but I checked on it today and it seems to be failing to start Chrome.

I’ve tried a few things without success. The official troubleshooting guide hasn’t gotten me anywhere and searching only pulls up advice for using puppeteer in functions, which isn’t useful for me.

Troubleshooting guide: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
Error message: Error: Failed to launch chrome!

FWIW, I’m using node 12.14.0.

The last successful build was on October 10. I have daily builds setup with zapier and none of them have worked. I have also been troubleshooting and rebuilding without success this evening.

Successful Log:

10:51:11 PM: Build ready to start
10:51:27 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
10:51:27 PM: build-image tag: v3.3.2
10:51:27 PM: buildbot version: 8727aab446158e7b8c8ad2e96fe74b0154505a4e
10:51:27 PM: Fetching cached dependencies
10:51:27 PM: Starting to download cache of 99.1MB
10:51:28 PM: Finished downloading cache in 866.127886ms
10:51:28 PM: Starting to extract cache
10:51:32 PM: Finished extracting cache in 3.7840482s
10:51:32 PM: Finished fetching cache in 4.707412073s
10:51:32 PM: Starting to prepare the repo for build
10:51:32 PM: Preparing Git Reference refs/heads/master
10:51:33 PM: Starting build script
10:51:33 PM: Installing dependencies
10:51:33 PM: Started restoring cached node version
10:51:36 PM: Finished restoring cached node version
10:51:37 PM: v10.16.3 is already installed.
10:51:38 PM: Now using node v10.16.3 (npm v6.9.0)
10:51:38 PM: Attempting ruby version 2.6.2, read from environment
10:51:39 PM: Using ruby version 2.6.2
10:51:40 PM: Using PHP version 5.6
10:51:40 PM: Started restoring cached node modules
10:51:40 PM: Finished restoring cached node modules
10:51:40 PM: Started restoring cached go cache
10:51:40 PM: Finished restoring cached go cache
10:51:40 PM: unset GOOS;
10:51:40 PM: unset GOARCH;
10:51:40 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
10:51:40 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
10:51:40 PM: go version >&2;
10:51:40 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
10:51:40 PM: go version go1.12 linux/amd64
10:51:40 PM: Installing missing commands
10:51:40 PM: Verify run directory
10:51:40 PM: Executing user command: npm install && npm run scrape && cd website && npm ci  && npm run build
10:51:47 PM: > puppeteer@1.19.0 install /opt/build/repo/node_modules/puppeteer
10:51:47 PM: > node install.js
10:51:56 PM: Chromium downloaded to /opt/build/repo/node_modules/puppeteer/.local-chromium/linux-674921
10:51:56 PM: npm
10:51:56 PM:  WARN r6-scraper@1.0.0 No repository field.
10:51:56 PM: added 19 packages from 20 contributors, removed 963 packages, updated 4 packages and audited 60 packages in 14.997s
10:51:56 PM: found 0 vulnerabilities
10:51:56 PM: > r6-scraper@1.0.0 scrape /opt/build/repo
10:51:56 PM: > npm cache clean --force && node build.js
10:51:57 PM: npm
10:51:57 PM: WARN using --force
10:51:57 PM:  I sure hope you know what you are doing.
10:52:06 PM: Added https://game-rainbow6.ubi.com/assets/data/seasons.11bfe9f0.json to manifest list.
10:52:06 PM: Added https://game-rainbow6.ubi.com/assets/locales/locale.en-us.32a22eb2.json to manifest list.
10:52:08 PM: Identified version as v2.3.6
.
.
.
10:52:44 PM: > docusaurus-build
10:52:50 PM: generate.js triggered...
10:52:51 PM: sitemap.js triggered...
10:53:38 PM: Site built successfully. Generated files in 'build' folder.
10:58:16 PM: Skipping functions preparation step: no functions directory set
10:58:16 PM: Caching artifacts
10:58:16 PM: Started saving node modules
10:58:16 PM: Finished saving node modules
10:58:16 PM: Started saving pip cache
10:58:16 PM: Finished saving pip cache
10:58:16 PM: Started saving emacs cask dependencies
10:58:16 PM: Finished saving emacs cask dependencies
10:58:16 PM: Started saving maven dependencies
10:58:16 PM: Finished saving maven dependencies
10:58:16 PM: Started saving boot dependencies
10:58:16 PM: Finished saving boot dependencies
10:58:16 PM: Started saving go dependencies
10:58:16 PM: Finished saving go dependencies
10:58:16 PM: Build script success
10:58:16 PM: Starting to deploy site from './website/build/api-docs'
10:58:17 PM: Creating deploy tree asynchronously
10:58:19 PM: 1 new files to upload
10:58:19 PM: 0 new functions to upload
10:58:19 PM: Starting post processing
10:58:22 PM: Post processing done
10:58:22 PM: Site is live
10:58:39 PM: Finished processing build request in 7m12.022918765s

Failed Log:

12:01:45 AM: Build ready to start
12:06:17 AM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
12:06:17 AM: build-image tag: v3.3.2
12:06:17 AM: buildbot version: 8727aab446158e7b8c8ad2e96fe74b0154505a4e
12:06:17 AM: Fetching cached dependencies
12:06:18 AM: Starting to download cache of 99.1MB
12:06:18 AM: Finished downloading cache in 1.147576678s
12:06:18 AM: Starting to extract cache
12:06:24 AM: Finished extracting cache in 5.37538485s
12:06:24 AM: Finished fetching cache in 6.553337648s
12:06:24 AM: Starting to prepare the repo for build
12:06:24 AM: Preparing Git Reference refs/heads/master
12:06:25 AM: Starting build script
12:06:25 AM: Installing dependencies
12:06:27 AM: Started restoring cached node version
12:06:30 AM: Finished restoring cached node version
12:06:31 AM: v10.16.3 is already installed.
12:06:32 AM: Now using node v10.16.3 (npm v6.9.0)
12:06:32 AM: Attempting ruby version 2.6.2, read from environment
12:06:34 AM: Using ruby version 2.6.2
12:06:34 AM: Using PHP version 5.6
12:06:34 AM: Started restoring cached node modules
12:06:34 AM: Finished restoring cached node modules
12:06:35 AM: Installing NPM modules using NPM version 6.9.0
12:06:43 AM: > puppeteer@1.20.0 install /opt/build/repo/node_modules/puppeteer
12:06:43 AM: > node install.js
12:06:52 AM: Chromium downloaded to /opt/build/repo/node_modules/puppeteer/.local-chromium/linux-686378
12:06:52 AM: npm WARN
12:06:52 AM:  r6-scraper@1.0.0 No repository field.
12:06:52 AM: added 18 packages from 19 contributors, removed 962 packages, updated 4 packages and audited 60 packages in 15.974s
12:06:52 AM: found 0 vulnerabilities
12:06:52 AM: NPM modules installed
12:06:52 AM: Started restoring cached go cache
12:06:52 AM: Finished restoring cached go cache
12:06:52 AM: unset GOOS;
12:06:52 AM: unset GOARCH;
12:06:52 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
12:06:52 AM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
12:06:52 AM: go version >&2;
12:06:52 AM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
12:06:53 AM: go version go1.12 linux/amd64
12:06:53 AM: Installing missing commands
12:06:53 AM: Verify run directory
12:06:53 AM: Executing user command: npm install && npm run scrape && cd website && npm ci  && npm run build
12:06:55 AM: npm
12:06:55 AM:  WARN r6-scraper@1.0.0 No repository field.
12:06:55 AM: audited 60 packages in 0.868s
12:06:55 AM: found 0 vulnerabilities
12:06:55 AM: > r6-scraper@1.0.0 scrape /opt/build/repo
12:06:55 AM: > npm cache clean --force && node build.js
12:06:55 AM: npm
12:06:55 AM: WARN
12:06:55 AM:  using --force
12:06:55 AM:  I sure hope you know what you are doing.
12:07:00 AM: Error: Failed to launch chrome!
12:07:00 AM: TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
12:07:00 AM:     at onClose (/opt/build/repo/node_modules/puppeteer/lib/Launcher.js:348:14)
12:07:00 AM:     at ChildProcess.helper.addEventListener (/opt/build/repo/node_modules/puppeteer/lib/Launcher.js:338:60)
12:07:00 AM:     at ChildProcess.emit (events.js:203:15)
12:07:00 AM:     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
12:07:00 AM: npm
12:07:00 AM:  ERR!
12:07:00 AM: code ELIFECYCLE
12:07:00 AM: npm
12:07:00 AM:  ERR! errno 1
12:07:00 AM: npm
12:07:00 AM: ERR! r6-scraper@1.0.0 scrape: `npm cache clean --force && node build.js`
12:07:00 AM: npm ERR! Exit status 1
12:07:00 AM: failed during stage 'building site': Build script returned non-zero exit code: 1
12:07:00 AM: npm ERR!
12:07:00 AM: npm ERR!
12:07:00 AM:  Failed at the r6-scraper@1.0.0 scrape script.
12:07:00 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:07:00 AM: Shutting down logging, 20 messages pending
12:07:00 AM: npm
12:07:00 AM:  ERR! A complete log of this run can be found in:
12:07:00 AM: npm ERR!     /opt/buildhome/.npm/_logs/2019-10-11T05_07_00_099Z-debug.log

I was launched without headless: true. Not sure why it was working on October 10, but an easy fix nonetheless.

Seems like the only difference between those logs is the puppeteer versions (1.19.0 vs 1.20.0). Perhaps, there was a default config change on the newer version that caused the issue. In any case, glad you resolved your issue.