Puppeteer isn't working in google cloud!
That chrome error is in the picture.
I already implemented the suggestion here: Puppeteer error on Heroku: Could not find Chromium
I also tried to downgrade my puppeteer version from 19.x to 18.x and 17.x but no luck.
I'll try using Playwright unless someone here has an idea of how to fix this...
EDIT: I've tried using puppeteer-chromium-resolver instead of puppeteer however now I am entirely unable to deploy my cloud function on node runtime 16 and 18.
EDIT 2: I've abandoned puppeteer-chromium-resolver in favor of chrome-aws-lambda and have added the following code snippet and deployed to Google cloud functions:
const bundledChromium = require('chrome-aws-lambda');
const playwright = require('playwright-core');
(async () => {
const browser = await Promise.resolve(bundledChromium.executablePath).then(
(executablePath) => {
console.log("executablePath: ", executablePath);
if (!executablePath) {
// local execution
return playwright.chromium.launch({});
}
return playwright.chromium.launch({ executablePath });
}
);
})()
the statement console.log("executablePath: ", executablePath);
prints "/tmp/chromium"
however I get another error:
2022-12-27 15:12:00.281 HKT
function-1ol6uqbjimrh1 Function execution started
2022-12-27 15:12:00.295 HKT
function-1ol6uqbjimrh1 executablePath: /tmp/chromium
2022-12-27 15:12:00.305 HKT
function-1ol6uqbjimrh1 Function execution took 24 ms, finished with status: 'ok'
2022-12-27 15:12:00.414 HKT
function-1ol6uqbjimrh1 browserType.launch: spawn EFAULT
2022-12-27 15:12:00.414 HKT
function-1ol6uqbjimrh1 =========================== logs ===========================
2022-12-27 15:12:00.414 HKT
function-1ol6uqbjimrh1 <launching> /tmp/chromium --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-K9OYeC --remote-debugging-pipe --no-startup-window
2022-12-27 15:12:00.414 HKT
function-1ol6uqbjimrh1 ============================================================
2022-12-27 15:12:00.414 HKT
function-1ol6uqbjimrh1 at /workspace/index.js:37:25
2022-12-27 15:12:00.414 HKT
function-1ol6uqbjimrh1 at async main (/workspace/index.js:30:21) {
2022-12-27 15:12:00.414 HKT
function-1ol6uqbjimrh1 name: 'Error'
2022-12-27 15:12:00.414 HKT
function-1ol6uqbjimrh1 }
Not sure how to proceed from here...
FINAL EDIT: I tried using AWS lambda with puppeteer in ECR and that didn't work either so I am using python selenium on pythonanywhere.com. This whole experience has been frustrating but at least selenium works.
Here's a link to a github for further details: https://github.com/Sparticuz/chromium/issues/29