playwright-aws-lambda icon indicating copy to clipboard operation
playwright-aws-lambda copied to clipboard

Does not work

Open blu-towers opened this issue 1 year ago • 4 comments

I have tried multiple ways for the last few days. Works perfectly fine locally but does not want to work on lambda, i have even tried Puppeteer with all the plugins i could find nothing works if anyone has something actually working in lambda let me know.

I think for now the best bet is full blown Docker and i have a mac silicone chip, yay https://github.com/JupiterOne/playwright-aws-lambda/issues/74

blu-towers avatar Nov 26 '24 07:11 blu-towers

Hello, I got it working today. It only worked for me with the following setup with NodeJS.

  • The dependencies in the package.json with these versions

“dependencies": { “playwright-aws-lambda": ‘^0.10.0’, “playwright-core": ”^1.49.1” }

  • NodeJs version 18.
  • In AWS Lambda (x86_64) manually lock the Node version to this version: arn:aws:lambda:us-east-1::runtime:0cdcfbdefbc5e7d3343f73c2e2dd3cba17d61dea0686b404502a0c9ce83931b9

This also worked in Ohio for me... arn:aws:lambda:us-east-2::runtime:0cdcfbdefbc5e7d3343f73c2e2dd3cba17d61dea0686b404502a0c9ce83931b9

F3lixP4lm avatar Jan 06 '25 10:01 F3lixP4lm

Thanks @F3lixP4lm, I'm faced issue like

[pid=13][err] /tmp/chromium: error while loading shared libraries: libnspr4.so: cannot open shared object file: No such file or directory

Sribalajivelan avatar Jan 07 '25 12:01 Sribalajivelan

I got things working by swapping to sparticruz + playwright-core

const chromium = require('@sparticuz/chromium');
const { chromium: playwright } = require('playwright-core');

    // In your handler route...
    const browser = await playwright.launch({
      args: chromium.args,
      executablePath: await chromium.executablePath(),
      headless: chromium.headless,
      chromiumSandbox: false,
    });
    const context = await browser.newContext();

    const page = await context.newPage();

alexseguin avatar Jul 31 '25 18:07 alexseguin

I got things working by swapping to sparticruz + playwright-core

const chromium = require('@sparticuz/chromium'); const { chromium: playwright } = require('playwright-core');

// In your handler route...
const browser = await playwright.launch({
  args: chromium.args,
  executablePath: await chromium.executablePath(),
  headless: chromium.headless,
  chromiumSandbox: false,
});
const context = await browser.newContext();

const page = await context.newPage();

What node version are you using?

karun012 avatar Aug 25 '25 10:08 karun012