Root CauseWhat broke, why, and the fix.

playwright install on one project deleted another project's browsers

· playwright, testing, automation, debugging
ⓘ Operated by TechAthletes. Every post here is a bug we hit in our own work — symptom, root cause, fix. Nothing is sponsored and we are not paid to mention any tool.

One of our end-to-end suites failed to start with:

Executable doesn't exist at .../chromium-1217/...

Nothing in that project had changed. No dependency bump, no config edit, no code touched since the last time the suite ran clean. The Chromium build it expected, revision 1217, was simply gone from disk, along with a WebKit build, revision 2272, that a different part of our setup used. Both had been sitting in the same shared cache directory for weeks.

What we assumed first

The obvious suspect was the project itself: a bad npm install, a lockfile drift, something that quietly swapped the pinned Playwright version and pointed it at a browser revision that was never downloaded. That theory predicts a reproducible failure tied to this one project's dependency tree, and it predicts that reinstalling that project's own node_modules would be the fix.

It also predicts something it should not: that the browser folder would still physically exist on disk, just unreferenced by the (allegedly broken) version resolution. That was worth checking before acting on the theory.

What we found instead

The browser folder was not merely unreferenced. It did not exist. ls on the shared cache directory came back without a chromium-1217 entry at all. Something had removed it, not a version-resolution bug pointing somewhere wrong.

That ruled out the dependency-drift theory and pointed at the cache directory itself — a location every local Playwright project on the machine shares, rather than something private to the failing project.

Catching the same thing happening live

A second, unrelated project on the same machine pins Playwright 1.60.0 and runs its own browsers independently. Running its install command:

playwright install chromium

installed a headless-shell build, revision 1223, for that project — the expected result. But the same command run also removed two other browser builds already sitting in the shared cache, revisions we call chromium-1248 and ffmpeg-1013 here, neither of which belonged to the project that ran the command.

That is the same shape of event as the original failure: a browser build disappearing from the shared cache as a side effect of an install run in a completely different project. We cannot point to the exact command that removed revision 1217 and 2272 at 22:53 the night before — that specific invocation was not captured — but watching the mechanism remove two more browsers live, in a run we did control, confirmed what kind of event this was.

What Playwright's own docs and source say is happening

Playwright documents this directly, under Stale browser removal:

Playwright keeps track of the clients that use its browsers. When there are no more clients that require a particular version of the browser, that version is deleted from the system.

That single sentence covers the entire incident. "Clients" here means local projects, not browsers in the usual sense, and the deletion is not a crash or a bug report — it is the intended behavior, running automatically.

The source backs up the specific mechanism. In playwright-core's registry code (packages/playwright-core/src/server/registry/index.ts), every project that runs an install command gets a reference file written into a .links subdirectory of the shared cache, named from a hash of that project's own path. Every time any project runs install again, Playwright reads every file in .links, follows each one back to its project's browsers.json, and builds the set of browser versions any currently-registered project still claims to need. Anything already downloaded that falls outside that set gets deleted — the function is literally named _deleteStaleBrowsers, called from _validateInstallationCache, which runs as part of every install.

Two details in that description matter more than they look. First, the check runs across every registered project on the machine, not just the one whose install command you happened to type. Second, it runs on every install call, not on some separate periodic job — there is no cron, no background daemon, just whichever project's npx playwright install happens to run next.

Put together: if a project's reference file in .links stops existing — because the project moved, got deleted, was reinstalled from a different path, or its reference simply went stale some other way — the garbage collector has no record that anything still needs that project's pinned browser version. The very next install run, from any project on that machine, will walk past that now-orphaned version and remove it. The project whose browser disappears does not have to do anything wrong itself; it just has to not be the one calling install when the sweep happens.

This is not a new mechanism. A 2021 Playwright issue, browsers are eventually removed when installed with Playwright CLI, describes the earlier version of this problem, and the fix that followed it — retaining browsers installed via the CLI by giving them their own link file — is where the current .links design comes from. The underlying trade-off the fix did not remove: multiple projects still share one cache, and the bookkeeping that keeps it tidy still runs globally.

What we actually did, and what we have not done yet

The recovery step we actually carried out was reinstalling browsers inside the project that lost one, which is exactly what we watched the second project do for itself: running playwright install chromium there pulled its headless-shell build back down and, as part of the same run, re-wrote that project's own .links entry. We have not yet gone back and confirmed, with the same deliberate test, that re-running install inside the originally affected project restores its missing Chromium and WebKit builds and keeps them from being swept next time — the documented mechanism says it should, since that install call is also what refreshes that project's reference file, but we are not calling that confirmed until we have watched it happen the same way we watched the cleanup itself.

Playwright's documentation lists three options for not getting caught by this again, and we have not applied any of them yet:

  • Give a project its own browser install path with PLAYWRIGHT_BROWSERS_PATH, which moves it out of the shared cache entirely (the "hermetic install" layout, typically under that project's own node_modules), at the cost of a larger, per-project install.
  • Opt out of the cleanup outright, either with the PLAYWRIGHT_SKIP_BROWSER_GC=1 environment variable or the --no-remove flag on the install command, so nothing gets removed as a side effect of someone else's install.
  • Before installing anything in one project, run playwright install --list first, to see what the shared cache currently holds across every registered project on the machine, and notice in advance if something you expect is already missing.

None of these are things we tried and found working; they are the options the documentation itself lists, left here undone rather than written up as if we had already run them.

The generalizable part

Any machine running more than one Playwright project against a shared cache has this exposure, regardless of how careful any single project's own setup is. The failure does not require the affected project to touch its own dependencies, its own config, or its own code at all. It only requires some other project on the same machine, pinned to some other Playwright version, to run an install command while the affected project's reference to its own browser has gone stale for any reason.

The useful habit coming out of this is to treat a shared browser cache the way you would treat any other shared, mutable resource between unrelated projects: check what else is relying on it before you act on it, and don't assume that an Executable doesn't exist error means your own project broke something. It may simply mean someone else, somewhere else on the machine, ran install first.

Root Cause is written while shipping small software products — you can see them at TechAthletes.

All posts →

Get new posts by email

We email you only when a new post goes up here. You can unsubscribe at any time.

Privacy policy