## TL;DR

Videos fail when the disk fills or the recorder misconfigures. Record only failures, clean artifacts between runs, and size the runner disk for the parallel worker count.

## Error

```text
Warning: video recording failed for test "checkout flow": unable to write video file.
```

## Steps

1. Check disk: `df -h` on the runner. Expected: confirms whether space is the issue.
2. Set `use: { video: 'retain-on-failure' }` in config. Expected: passing tests stop writing video.
3. Delete `test-results/` at the start of each CI job. Expected: no accumulation across runs.
4. If videos are still huge, lower `video: { mode }` size or disable for the fastest specs. Expected: artifact size under control.
5. Re-run a failing test and confirm the video exists. Expected: failures have video, passes do not waste disk.

## When to use

- Missing videos on failures, or disk-full runners.
- CI with small disks and many parallel workers.

## When not to use

- Traces missing (separate option).
- You need video of passes for compliance (then provision disk).

## Tool compatibility

- Playwright 1.30 through latest; `video` option in config.

## Variant phrasings

### Playwright did not save video on failure

Check the `video` mode; `off` and `on-first-retry` behave differently.

### video file is 0 bytes

The recorder started but the disk filled mid-write.

## Why it happens

Video is written per test per worker. Parallel workers multiply disk usage, and small CI disks fill fast.

## Edge cases

- `video: 'on'` for every test is the most expensive setting; prefer `retain-on-failure`.
- WebKit video encoding is slower; on weak runners it can time out the test teardown.
- Uploading videos to artifact storage also needs bandwidth budget.

## Provenance

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