question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Monorepo breaks build for Cloud Functions

See original GitHub issue

Bug description

Steps to reproduce the problem:

  1. Depend on puppeteer 19.0.0 in a Cloud Function.
  2. Deploy the Cloud Function, the build succeeds.
  3. Invoke the Cloud Function, the error below occurs.

My guess is that the new cache location is not retained in the final Docker image for the Cloud Function. Although the build (and probably the download of Chromium) succeeds, Chromium is not available at runtime.

While the Cloud Function environment is not a direct concern of the puppeteer project, the caching feature introduced in 19.0.0 makes it hard to reliably install Chromium in an environment where we don’t control the build/file system. I’ve tried playing around with PUPPETEER_CACHE_DIR, but again, we have very little guarantees over the build flow and it potentially changing.

Instead of specifying a download location using PUPPETEER_CACHE_DIR, is there any way the old behaviour can optionally be turned on, and let puppeteer figure out where it’s installed? This would avoid having to know the subtlety of the underlying build/file system.

Thanks,

Puppeteer version

19.0.0

Node.js version

16

npm version

8.5.0

What operating system are you seeing the problem on?

Linux

Relevant log output

Error: Could not find expected browser (chrome) locally. Run `npm install` to download the correct Chromium revision (1045629).

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:5
  • Comments:39 (5 by maintainers)

github_iconTop GitHub Comments

8reactions
jrandolfcommented, Oct 23, 2022

This is fixed. Just add .puppeteerrc.cjs at the root of your app directory with

const {join} = require('path');

/**
 * @type {import("puppeteer").Configuration}
 */
module.exports = {
  cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
};
3reactions
jketchamcommented, Oct 28, 2022

Wanted to chime in and mention this effected me when I upgraded from v16 to v19 while deploying puppeteer to a Cloud Function.

If a solution could be implemented that didn’t involve having to create an extra configuration file, that’d be awesome. I’ve downgraded to v18 for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firebase Functions + monorepo - Deploying doesn't work + ...
when I do firebase deploy , same error. If instead of running the command from the root folder I do it from packages/functions/package.json...
Read more >
Improved mono-repo for Typescript + Cloud Function ...
I've addressed this using yarn workspaces and following a mono-repo pattern that is common when developing node packages. This approach means ...
Read more >
Deploying monorepo w/ react front-end & firebase functions ...
Hey all! The project we're working with is a monorepo w/ 2 package.json files. JS front-end (react/CRA), Firebase cloud functions back-end.
Read more >
Gcloud Functions Deploy can't find yarn workspace [213632942]
I'm using yarn berry workspaces in a nodejs / typescript project. I have a google-cloud package that I've created and that a dependent...
Read more >
Troubleshooting build errors | Cloud Build Documentation
Permission denied error when deploying on Cloud Functions ... as well as solutions for some common error messages that you might see when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found