JSPM

  • Created
  • Published
  • Downloads 8739
  • Score
    100M100P100Q118382F
  • License MIT

Run headless Chrome/Chromium on AWS Lambda

Package Exports

  • @serverless-chrome/lambda

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@serverless-chrome/lambda) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

serverless-chrome/lambda

Standalone package to run Headless Chrome in AWS Lambda.

Contents

  1. Installation
  2. Setup
  3. Testing
  4. Configuration and Deployment
  5. Known Issues / Limitations
  6. Roadmap
  7. Troubleshooting

Installation

Install with yarn:

yarn add @serverless-chrome/lambda

Install with npm:

npm install --save @serverless-chrome/lambda

Setup

Use in your AWS Lambda function. Requires Node 6.10.

todo: check that this code works:

const launchChrome = require('@serverless-chrome/lambda')
const CDP = require('chrome-remote-interface')

module.exports.handler = function handler (event, context, callback) {
  launchChrome({
    flags: ['--window-size=1280x1696', '--hide-scrollbars']
  })
  .then((chrome) => {
    // Chrome is now running on localhost:9222

    CDP.Version()
      .then((versionInfo) => {
        callback(null, {
          versionInfo,
        })
      })
      .catch((error) => {
        callback(error)
      })
  })
  .catch((error) => {
    // Chrome didn't launch correctly

    callback(error)
  })
}

TODO:

add part about how we use lighthouse-launcher, and it'll launch other Chrome on non-lambda env for use in dev.