fs.rmSync blocks the Electron main process for as long as it takes to unlink every file, and a Chromium profile folder has hundreds of them. Mosaic used it to empty the trash. On 29 September 2026 we measured twenty profiles taking 0.70 seconds, and in that time the local API answered one request. The app was not slow. It was stopped.
"Deleting a bunch of things from trash almost crashed my PC"
That was the report. Nothing crashed, but from the outside a frozen main process and a crash look much the same: the window stops drawing, clicks queue up, and macOS starts offering to force-quit.
The code path was short. purgeProfile removed a profile's browser data with:
rmSync(dir, { recursive: true })
and emptyTrash called purgeProfile in a loop. A Chromium profile folder is not one file. On our machine they held between 488 and 849 entries and 16 to 53 MB each: caches, databases, journals, extension state. rmSync makes every one of those unlink calls on the thread that also runs the window, the IPC handlers and the REST server.
How we measured rmSync blocking the main process
We seeded twenty profiles with a real profile's data, so each folder looked like one that had been used. Then we called POST /trash/empty against the running app while a second thread polled the API as fast as it could.
POST /trash/empty 0.70 s API answered 1 request in that window
One answer in 0.70 seconds is the number that matters. A duration alone would have said the purge was a bit slow. The request count says nothing else in the process ran. A real trash holds a hundred-odd rows, not twenty, so in practice this was several seconds of a beachballed application.
We will not see this on our own machines unless we look for it. A developer testing the trash deletes three profiles that have never been opened, and each folder is a handful of files.
Make 500 profiles in one go, then work on all of them at onceIn Mosaic: Bulk actions. 500 profiles per batch; start, edit and type into many. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.
Mosaic is a desktop app
Email yourself the link and open it on your computer.
Two suspects that were innocent
Both of these looked like the cause, and each took a measurement to rule out.
- The store write. Mosaic's state file is saved through a 150 ms debounce. The loop is synchronous, so the timer cannot fire inside it, and the whole purge writes the file once, at the end.
- The safety snapshot. A purge takes a backup of the library first, and that is coalesced to one per 60 seconds. It copies the profiles' JSON, not their browser data, so it is small, and a purge of any size takes one.
Both were already correct. The time was all in unlink.
A rename is one operation
Renaming a folder costs the same whether it holds one file or eight hundred. So the purge now does the part that has to happen at once, which is removing the index entry and the profile's own JSON, and then moves the data folder aside:
purgeDataDirrenames the folder intoprofile-data/.purging/, under a fresh name, so two profiles purged in one burst cannot collide.- The recursive delete goes to
fs.promises.rm, which runs on libuv's thread pool, off the main thread. - If the rename itself fails, it falls back to the old synchronous delete. A staging folder we cannot write to must not turn a purge into a no-op that leaves the data in place.
- At startup, a sweep deletes anything left in
.purging, because a rename that lands followed by a quit leaves a folder nothing points to.
Same twenty profiles, after:
POST /trash/empty 0.06 s and the process answers during it
We also checked the bytes really went. All twenty folders were gone from disk, .purging was empty, and the data folder dropped from 1.1 GB to 649 MB. A purge that only looks fast because it stopped deleting would be the worse bug.

The rule we wrote down
Synchronous filesystem work in the main process is a freeze whose length depends on someone else's data. The folder size is set by how much the person browsed, not by anything in our code. And when you test a destructive path, poll the process during it. A timer says the path was slow; the number of requests answered says whether it stopped.
Trashing a profile also closes its browser before anything is moved, which is its own story in trashing a profile closes its browser. Move to trash in the bulk bar deletes nothing; the files go when you press Delete on a row in the trash, press Empty trash, or the 30 days run out, and all three take the same rename-then-delete path. Over the local REST API it is POST /trash/empty, which refuses to run until the body says what to empty. The profiles, their trash and the staging folder all stay on your computer, as local-first describes.






