Cypress "out of memory or has crashed" - Browser Crash in CI
The browser Cypress drives ran out of memory and was killed mid-run. Chromium accumulates DOM snapshots and memory across a long spec, and a small container shared-memory limit makes it crash.
What this error means
The run dies with "The Test Runner unexpectedly exited" and "We detected that the Chromium Renderer process just crashed... the browser ran out of memory." Remaining specs are skipped; it is an infrastructure crash, not an assertion failure.
The Test Runner unexpectedly exited via a exit event with signal SIGTRAP
We detected that the Chromium Renderer process just crashed.
This is the equivalent to seeing the 'sad face' when Chrome dies.
... the browser ran out of memory.Diagnose it: browser, server, or timing?
End-to-end failures in CI are dominated by three causes that have nothing to do with the test: the browser binary is missing, the application under test is not listening yet, or the test raced the page. Establish which before reading the assertion.
# 1. are the browsers actually installed in THIS job?
npx playwright install --with-deps chromium
npx playwright --version
# 2. is the app up before the tests start?
npx wait-on http://localhost:3000 --timeout 60000
# 3. capture evidence for the failure you cannot reproduce
npx playwright test --trace on --video retain-on-failureCommon causes
Snapshot memory growth over a long spec
Cypress keeps command snapshots for time-travel debugging. Across hundreds of commands in one spec, browser memory climbs until the renderer is OOM-killed.
Small container shared memory (/dev/shm)
Docker defaults /dev/shm to 64 MB. Chromium uses shared memory heavily and crashes when it is exhausted on a constrained CI container.
How to fix it
Reduce snapshot memory pressure
Turn down numTestsKeptInMemory and disable in-memory snapshots in CI runs.
// cypress.config.js
module.exports = {
numTestsKeptInMemory: 0,
e2e: { experimentalMemoryManagement: true },
};Give Chromium more shared memory
# Docker: raise /dev/shm or disable Chromium's use of it
docker run --shm-size=2g ...
# or pass the flag to the browser
# launchOptions.args.push('--disable-dev-shm-usage')Make the browser cache safe
- Key the browser cache to the exact test-runner version. A cache restored from a different version gives you a binary that does not match the client and fails in a way that reads like a missing install.
- Install browsers after dependencies, not before; a dependency install can replace the package that owns the browser path.
- Prefer the vendor container image when the runner allows it. It removes the whole class of missing-system-library failures.
How to prevent it
- Set
experimentalMemoryManagementand a lownumTestsKeptInMemoryin CI. - Run on containers with
--shm-sizeraised (or--disable-dev-shm-usage). - Split very long specs to cap per-spec memory growth.