# Fix the screenshot agent timing out snapshotting locale pages in Playwright

## TL;DR

Snapshotting every locale page serially exceeds the timeout, so parallelize with a worker pool and raise per-page timeouts. Locale suites multiply pages by languages, and serial runs time out. Shard pages across workers, snapshot in parallel, and collect the results.

## The error

```text
Screenshot agent: timed out snapshotting 200 locale pages
Playwright run failed after 30 minutes, 40 pages captured
```

## Fix it

### Step 1: Count the page-locale combinations

```bash
node -e "console.log('pages times locales = total snapshots, check the number')"
```

Expected: You see the scale that serial runs cannot meet.

### Step 2: Shard across workers

```bash
node -e "console.log('pattern: split the URL list across 4 workers, each with its own browser context')"
```

Expected: Snapshots parallelize.

### Step 3: Raise the per-page timeout sanely

```bash
node -e "console.log('60s per page with 4 workers beats one 30-minute global timeout')"
```

Expected: Slow pages fail alone instead of killing the run.

### Step 4: Re-run and confirm full coverage

```bash
node scripts/locale-shots.js | tail -3
```

Expected: All 200 pages captured.

## When to use this

- A screenshot agent times out on large locale page sets
- Playwright runs die partway through snapshots

## When NOT to use this

- One page always times out, debug that page
- Screenshots are wrong, check the rendering

## Tool and version compatibility

- Playwright worker pools, sharded snapshot runs
- Per-page timeouts

## Variant phrasings

### workers exhaust memory

Fewer workers with more RAM each, or restart contexts between shards.

### CI is slower than local

Size the pool for CI, not your laptop. Detect CI and shrink the pool.

## Why it happens

Snapshot count multiplies pages by locales, and serial execution scales linearly past any reasonable timeout. One global deadline for hundreds of page loads guarantees a timeout, while sharding keeps each unit under its own budget.

## Edge cases

- Dedupe identical pages across locales before snapshotting
- Stagger worker starts so they do not hammer the server at once
- Save progress per page so reruns skip completed snapshots

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_Xg4Yz8xzR8s_vLpIebpVwA
