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: open
- Created 2 months ago
- Reactions: 2
- Comments: 31 (3 by maintainers)
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.
setting this works
chromium.setGraphicsMode = true;
FWIW I was able to get it working with:
I rolled back manualy the runtime version and it worked
This works for us.
We migrated to a previous version of Runtime on lambda(Node.Js 18.*)
package.json for compatibility.
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
@ryan-concora Specify the run time management at the “provider” or “function” level in your
serverless.yml
file: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
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 )
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.