Function cannot start puppeteer when invoked via local http server.
Working properly with serverless-offline 5.x
Breaking with version 6.x (6.0.0-alpha.67) - no changes made in the code, just switching versions
Error thrown when endpoint is hit.
Endpoint returns 502 Bad Gateway
and following error and stack trace is thrown:
````
Error: Failed to launch the browser process! spawn %userprofile%\AppData\Local\Temp\chromium ENOENT
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
at onClose (...redacted...\services\checker\node_modules\puppeteer\lib\Launcher.js:750:14)
at ChildProcess.<anonymous> (...redacted...\services\checker\node_modules\puppeteer\lib\Launcher.js:741:65)
at ChildProcess.emit (events.js:311:20)
at ChildProcess.EventEmitter.emit (domain.js:482:12)
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
````
even though chromium binary exists in the path mentioned in the stack trace
I am able to reproduce it by running sls offline and hitting POST http://localhost:3000/dev
org: someorg
app: someapp
service: checker
provider:
name: aws
region: eu-west-1
versionFunctions: false
layers:
- arn:aws:lambda:${self:provider.region}:764866452798:layer:chrome-aws-lambda:8
# function parameters
runtime: nodejs12.x
memorySize: 1024
timeout: 30
functions:
check:
handler: src/handler.check
events:
- http:
path: /
method: post
request:
parameters:
paths:
url: true
plugins:
- serverless-jest-plugin
- serverless-offline
package:
exclude:
- node_modules/puppeteer/.local-chromium/**
const chromium = require('chrome-aws-lambda');
exports.check = async (event, context) => {
let result;
try {
browser = await chromium.puppeteer.launch({
args: chromium.args,
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath,
headless: false,
ignoreDefaultArgs: ['--disable-extensions']
});
let page = await browser.newPage();
const response = await page.goto(event.url || 'https://example.com');
result = response.status();
} catch (error) {
return context.fail(error);
} finally {
if (browser !== null) {
await browser.close();
}
}
return context.succeed(result);
};
Puppeteer is launched as expected.
Environment
serverless version: 1.65.0serverless-offline version: 6.0.0-alpha.67node.js version: 12.16.1OS: Windows 10+1 on 6.0.0
same issue with ^6.1.4
The same issue with ^6.4.0 as well
Could someone provide an example repository for this issue? I have been working with pupeteer recently and will take a look.
Still having this issue as well. Worked fine for me as well on v5.