title: Puppeteer + AWS Lambda - Could not find browser revision
body: <p>I have been trying to get puppeteer working on AWS Lambda, but am running into an error. The message I receive is:</p>
  <p><strong>&quot;error&quot;: &quot;Could not find browser revision 782078. Run &quot;PUPPETEER_PRODUCT=firefox npm install&quot; or &quot;PUPPETEER_PRODUCT=firefox yarn install&quot; to download a supported Firefox browser binary.&quot;</strong></p>
  <p>I have enough memory allocated to this specific lambda to run the function around 11s.</p>
  <p><strong>The error only shows on cold starts</strong></p>
  <p>The function runs well offline with 100% success. LOCAL=true is set when running offline, so there is code to distinguish between the two baked in here.</p>
  <p>Here are the important parts of my code regarding this lambda.</p>
  <pre><code>import chromium from &quot;chrome-aws-lambda&quot;;
  import { inflate } from &quot;lambdafs&quot;;
  import path from &quot;path&quot;;
  
  const isLocal = !!process.env.LOCAL;
  
  process.env.HOME = &quot;/tmp&quot;;
  if (process.env.FONTCONFIG_PATH === undefined) {
    process.env.FONTCONFIG_PATH = &quot;/tmp/aws&quot;;
  }
  
  if (process.env.LD_LIBRARY_PATH === undefined) {
    process.env.LD_LIBRARY_PATH = &quot;/tmp/aws/lib&quot;;
  } else if (process.env.LD_LIBRARY_PATH.startsWith(&quot;/tmp/aws/lib&quot;) !== true) {
    process.env.LD_LIBRARY_PATH = [...new Set([&quot;/tmp/aws/lib&quot;, ...process.env.LD_LIBRARY_PATH.split(&quot;:&quot;)])].join(&quot;:&quot;);
  }
  
  let input;
  if (!isLocal) {
    input = &quot;/opt/nodejs/node_modules/chrome-aws-lambda/bin&quot;;
  } else {
    input = path.resolve(__dirname, &quot;../node_modules/chrome-aws-lambda/bin&quot;);
  }
  
  const blockedResourceTypes = [&quot;image&quot;, &quot;media&quot;, &quot;font&quot;, &quot;texttrack&quot;, &quot;object&quot;, &quot;beacon&quot;, &quot;csp_report&quot;, &quot;imageset&quot;];
  
  const skippedResources = [
    &quot;quantserve&quot;,
    &quot;adzerk&quot;,
    &quot;doubleclick&quot;,
    &quot;adition&quot;,
    &quot;exelator&quot;,
    &quot;sharethrough&quot;,
    &quot;cdn.api.twitter&quot;,
    &quot;google-analytics&quot;,
    &quot;googletagmanager&quot;,
    &quot;fontawesome&quot;,
    &quot;facebook&quot;,
    &quot;analytics&quot;,
    &quot;optimizely&quot;,
    &quot;clicktale&quot;,
    &quot;mixpanel&quot;,
    &quot;zedo&quot;,
    &quot;clicksor&quot;,
    &quot;tiqcdn&quot;,
  ];
  
  export async function handler(event) {
    const credentials = {
      userName: event.userName,
      password: event.password,
      site_login_id: event.site_login_id,
      user_id: event.juice_userid,
    };
  
    let chrome, aws, shader;
  
    (async () =&gt; {
      chrome = await inflate(`${input}/chromium.br`);
      shader = await inflate(`${input}/swiftshader.tar.br`);
      aws = await inflate(`${input}/aws.tar.br`);
    })();
  
    const chromePath = isLocal ? undefined : chrome;
  
    const puppeteer = chromium.puppeteer;
  
    const browser = await puppeteer.launch({
      args: chromium.args,
      defaultViewport: chromium.defaultViewport,
      executablePath: chromePath,
      ignoreDefaultArgs: [&quot;--disable-extensions&quot;],
      headless: true,
    });
  }
  </code></pre>