Sparticuz / chromium

Chromium (x86-64) for Serverless Platforms
MIT License
1.02k stars 71 forks source link

[BUG] Failed to launch the browser process! on AWS Lambda #263

Open sriramwarsaicharan opened 7 months ago

sriramwarsaicharan commented 7 months ago

Environment

Expected Behavior

I need to open the browser on aws lambda.

Current Behavior

"OUT:Error: Failed to launch the browser process!\n\n\nTROUBLESHOOTING: https://pptr.dev/troubleshooting\n"

TROUBLESHOOTING: https://pptr.dev/troubleshooting

at Interface.onClose (/opt/nodejs/node_modules/@puppeteer/browsers/lib/cjs/launch.js:310:24)
at Interface.emit (node:events:530:35)
at Interface.emit (node:domain:488:12)
at Interface.close (node:internal/readline/interface:527:10)
at Socket.onend (node:internal/readline/interface:253:10)
at Socket.emit (node:events:530:35)
at Socket.emit (node:domain:488:12)
at endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Steps to Reproduce

const puppeteer = require("puppeteer-core"); const chromium = require("@sparticuz/chromium"); const aws = require('aws-sdk'); const fs = require('fs')

exports.handler = async (event, context, callback) => { let result = null; let browser = null;

try { browser = await puppeteer.launch({ args: chromium.args, defaultViewport: chromium.defaultViewport, executablePath: await chromium.executablePath(), headless: chromium.headless, ignoreHTTPSErrors: true, });

let page = await browser.newPage();

await page.goto(event.url || 'https://example.com');

result = await page.title();

} catch (error) { return callback(error); } finally { if (browser !== null) { await browser.close(); } }

return callback(null, result); };

sriramwarsaicharan commented 7 months ago

I need help to make this browser run on aws lambda in headless mode

riyahudle commented 4 months ago

Facing same issue