-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lambda deployed with CDK - ENOENT: no such file or directory, open '/var/task/bin/chromium.br #64
Comments
Yes I feel like a step is missing here |
@revmischa now it's working for me, but I don't remember exactly what unlocked me, I forgot to update back this issue once it started to work. What I have now: Lambda layer contents: npm install --prefix layer/nodejs -s chrome-aws-lambda playwright-core playwright-aws-lambda CDK: const layer = new lambda.LayerVersion(this, "ChromeLayer", {
// run npm install --prefix layer/nodejs -s chrome-aws-lambda playwright-core playwright-aws-lambda
code: lambda.Code.fromAsset("./layer"),
});
new NodejsFunction(scope, id, {
runtime: lambda.Runtime.NODEJS_16_X,
memorySize: 1024,
bundling: {
externalModules: [
"chrome-aws-lambda",
"playwright-core",
"playwright-aws-lambda",
],
},
layers: [layer],
timeout: Duration.minutes(15),
}); then on a lambda: const playwright = require('playwright-aws-lambda');
// ...
const browser = await playwright.launchChromium({ headless: true }); |
This is what I did for bundling settings in Serverless Stack: hooks: {
beforeBuild: async (props, outDir) => {
// create bin folder
const binDir = path.join(outDir, "bin")
if (!fs.existsSync(binDir)) fs.mkdirSync(binDir, { recursive: true })
},
},
copyFiles: [
{
from: "backend/node_modules/playwright-aws-lambda/dist/src/bin/aws.tar.br",
to: "./bin/aws.tar.br",
},
{
from: "backend/node_modules/playwright-aws-lambda/dist/src/bin/chromium.br",
to: "./bin/chromium.br",
},
{
from: "backend/node_modules/playwright-aws-lambda/dist/src/bin/swiftshader.tar.br",
to: "./bin/swiftshader.tar.br",
},
], but it's quite hacky |
Hello @phstc @revmischa, I am facing the "almost" same issue here: |
@clementmarcilhacy try marking the chromium dep as external in your sst function config, eg.:
|
Hey I am having a similar issue. I have tried to follow your steps to install the dependencies on the layer. Now I have a new folder for the layer but I can't connect with the current function folder. Also, where do you specify the CDK code? I tried adding it to MyStack.ts but I'm missing the lambda import |
I'm deploying a NodejsFunction, and I'm getting this error invoking my lambda:
NodejsFunction uses esbuild that compresses the lambda code. Therefore, missing chromium binaries.
Is anyone doing something similar with a
NodejsFunction
that could share some snippets?The text was updated successfully, but these errors were encountered: