alixaxel / chrome-aws-lambda

Chromium Binary for AWS Lambda and Google Cloud Functions
MIT License
3.22k stars 293 forks source link

Update example usage #259

Open otterley opened 2 years ago

otterley commented 2 years ago

Update the example provided in the main README file. In this update, we preserve the browser object across Lambda function invocations, reducing latency by several hundred milliseconds per execution that would otherwise be spent re-loading and starting the browser executable.

The updated example also updates the handler function call signature and eliminates unnecessary exception handling. Finally, we return the value instead of invoking the callback as per the Lambda function handler documentation for Node.js:

For async handlers, you return a response, error, or promise to the runtime instead of using callback.

gerwin-so commented 2 years ago

There is an issue with this approach though, and a workaround seems to be to always keep a page open: https://github.com/alixaxel/chrome-aws-lambda/issues/217