chromium: [BUG] No longer working in Lambda
package.json:
"@sparticuz/chromium": "123.0.1",
"puppeteer-core": "22.6.4"
code:
chromium.setGraphicsMode = false;
console.log("## Launching browser");
const browser = await puppeteer.launch({
args: chromium.args,
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath(),
headless: chromium.headless,
ignoreHTTPSErrors: true,
});
console.log("## Creating new page");
const page = await browser.newPage();
console.log("## Setting user agent");
await page.setUserAgent("Lambda PDF");
console.log("## Going to " + url);
await page.goto(url, {
waitUntil: ["domcontentloaded", "networkidle0"],
});
It’s freezing after “Creating new page” appears in the console logs.
Lambda 18.x (tried with 20.x too) with 2GB memory
Runtime version ARN: arn:aws:lambda:eu-west-2::runtime:b475b23763329123d9e6f79f51886d0e1054f727f5b90ec945fcb2a3ec09afdd
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 11
- Comments: 48 (3 by maintainers)
Commits related to this issue
- ✨ Feat: setGraphicsMode 임시 활성화 https://github.com/Sparticuz/chromium/issues/271 # — committed to team-everfrost/scraping-lambda by ks1ksi 2 years ago
Downgrading to:
Seems to have worked. Leaving this open just to verify I didnt make a mistake selecting the wrong package versions?
Yes, AWS updated some libraries that are causing issues with the libraries included in this package. I’m in contact with the team at AWS and we will be working on a solution.
I would recommend pinning the lambda execution environment while this issue gets sorted.
@Sparticuz any news on this? Pinning to older version for a long run is not perfect solution for security reasons.
@ryan-concora Specify the run time management at the “provider” or “function” level in your
serverless.ymlfile:The ARN version in the example above works for me (The offending ARN is mentioned in OP: https://github.com/Sparticuz/chromium/issues/271#issue-2271372222) Reference: https://www.serverless.com/framework/docs-providers-aws-guide-functions
This works for us.
We migrated to a previous version of Runtime on lambda(Node.Js 18.*)
package.json for compatibility.
setting this works
chromium.setGraphicsMode = true;Working with runtime above by configure lambda runtime manually
@raducretu you can specify the exact version of the runtime under something called “runtime management configuration”. If you look at your logs from when things worked (a few days ago) you should see which arn they are using as it’s printed in the INIT_START. Look for your old arn that worked, and then go in and change it to that for your Lambda.
More info here: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-update.html
FWIW I was able to get it working with:
Our solution:
This worked, thankyou
I rolled back manualy the runtime version and it worked
We’ve worked around it by rolling back to the previous Lambda Runtime ARN.
We have also started facing same issue. We have not update package version from 3 months. While trying to figure out the issue, we found that it is not working only when html contains https URLs as we had some https URLs in img tag and link tag. With http urls, it is working fine.
We had the following package.json
Same thing is working fine with https URLs after updating package version to (as mentioned by @fire015 )
version 123.0.1 seems to be working again on my end. not sure what the root cause is. I have tested generating more than 100 PDFs today and it works properly.
lib version: https://github.com/Sparticuz/chromium/releases/tag/v123.0.1
package.json
code:
Lambda runtime
edit: set graphics mode to true seems fix the problem
To everyone who’s reading this thread looking for answers for Vercel, what eventually worked for me:
(I’m not sure what here is responsible for a fix)
Just in case: puppeteer-core is “^21.3.8”
how we do now is store the ARN into SSM then map to runtimemanagement > arn
For everyone that is still experiencing issues after pinning the runtime version: check if you’re properly closing the browser at the end of your lambda.
Our function was running fine for over a year with puppeteer-core
19.7.4and chromium111.0.0. After pinning the runtime version, it was kind of working again, but crashed regularly under load. Turns out we never closed the browser, which hasn’t been an issue before. Changingto
along with pinning the version fixed the issues for us, it’s been running fine for a few hours now.
I am curious about the root cause, seems it relate to SSL lib update, but why GraphicsMode can make it solved.
Removing our disabling of the graphics mode solved this for us:
with the following versions:
edit: actually, not sure about this, we’re still seeing some errors
Make sure to leave graphics mode enabled. The option will be fixed in the next version. I’ve been traveling so I haven’t had time to update to chromium 124.