# Playwright Lambda Layer Errors

Common Playwright errors on Lambda usually come from missing browser binaries,
missing shared libraries, launch flags, or memory pressure.

Plain text for agents: https://riddledc.com/guides/playwright-lambda-layer-error/markdown.md

## Error: Executable doesn't exist

```text
browserType.launch: Executable doesn't exist at /var/task/node_modules/playwright/.local-browsers/chromium-xxx/chrome-linux/chrome
```

Playwright downloads browser binaries during install, but Lambda deployment
packages often omit the binary or the required system libraries.

## Error: Missing System Libraries

```text
error while loading shared libraries: libnss3.so: cannot open shared object file
error while loading shared libraries: libgtk-3.so.0: cannot open shared object file
```

Lambda's Amazon Linux runtime is missing GUI libraries that Chromium still
needs in headless mode. A layer can provide them, but layer ARNs vary by
region and change over time.

## Error: Protocol Timeout

Chrome needs Lambda-specific launch flags such as `--no-sandbox`,
`--disable-dev-shm-usage`, and `--single-process`. Missing flags can lead to
immediate crashes or browser launch timeouts.

## Error: Out of Memory

Chromium needs far more memory than Lambda's default 128 MB. Teams often move
to 1536 MB or 2048 MB and still need to close browser processes carefully.

## The Pattern You're Fighting

The common loop is install `playwright-core`, add `@sparticuz/chromium`, add a
Lambda Layer, configure launch args, raise memory, deploy, hit another error,
and repeat when the Chromium package updates.

## Alternative: Skip the Layer Dance

Call the Riddle API instead of launching Playwright in Lambda:

```js
export async function handler(event) {
  const response = await fetch("https://api.riddledc.com/v1/run", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.RIDDLE_API_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({ url: event.url })
  });

  return {
    statusCode: 200,
    body: Buffer.from(await response.arrayBuffer()).toString("base64"),
    isBase64Encoded: true
  };
}
```

That means no layers to manage, no browser binary in the deployment package,
and no Chrome-specific Lambda errors.

