Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] support optional CHROME_AWS_LAMBDA_ASSUME_HEADLESS override environment variable #272

Open
tmeneau opened this issue Apr 28, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@tmeneau
Copy link

tmeneau commented Apr 28, 2022

What would you like to have implemented?

Support an environment variable (such as CHROME_AWS_LAMBDA_ASSUME_HEADLESS) to optionally short circuit the serverless variable checks in Chromium.headless. For example, this could look like:

  static get headless() {
    if (process.env.CHROME_AWS_LAMBDA_ASSUME_HEADLESS === undefined &&
          (process.env.IS_LOCAL !== undefined || process.env.IS_OFFLINE !== undefined)) {
      return false;
    }
    ...
  }

Why would it be useful?

This would allow users to independently handle weird edge/use cases with minimal changes to their code and/or environments. My own use case is running an app using chrome-aws-lambda in a docker container using the AWS NodeJS Lambda image to locally emulate our production lambda environment (including using the bundled chromium), but overriding the entrypoint to use serverless-offline to mock an AWS API Gateway we have upstream of our Lambda function.

However, it looks like there are a few other edge cases that could also be served by this:

Alternative (Backwards Incompatible) Proposal

You could also make the argument that the problem here is assuming whether the user wants headless or not based on a potential breadcrumb of a specific runtime environment, rather than letting the user specifically define it. While this might be too much of a breaking change at this point, I'd think this would be less confusing for users:

  static get headless() {
    if (process.env.CHROME_AWS_LAMBDA_DISABLE_HEADLESS) {
      return false;
    }
    ...
  }

Users could then explicitly explicitly disable the headless check.

@tmeneau tmeneau added the enhancement New feature or request label Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant