Last week, I wrote about a cool new API in Bun called WebView that makes it possible to open a URL in a headless browser without needing something like Puppeteer or Playwright. The code looks like this:


import { WebView } from "bun"

await using view = new WebView({ width: 2000, height: 3000 })
await view.navigate(url)

// example, evaluate JavaScript 
console.log(await view.evaluate("document.body.innerHTML"))

// example, take a screenshot
const png = await view.screenshot()
await Bun.write(values.screenshot, png)

However, there's a drawback: each time I run a process like this on my Ubuntu 20.04 server, it creates directories such as /tmp/snap-private-tmp/snap.chromium/tmp/bun-chrome-80856 and /tmp/snap-private-tmp/snap.chromium/tmp/org.chromium.Chromium.YL1S7L.

After I've run the above Bun code five times, I see this:

root@ubuntu-s-2vcpu-8gb-amd-nyc3-01:~# ls -l /tmp/snap-private-tmp/snap.chromium/tmp/
total 0
drwx------ 31 django django 740 Apr 29 12:30 bun-chrome-80651
drwx------ 31 django django 740 Apr 29 12:30 bun-chrome-80856
drwx------ 31 django django 740 Apr 29 12:30 bun-chrome-81058
drwx------ 31 django django 740 Apr 29 12:30 bun-chrome-81260
drwx------ 31 django django 740 Apr 29 12:30 bun-chrome-81459
drwx------  2 django django  80 Apr 29 12:30 org.chromium.Chromium.3zCHrv
drwx------  2 django django  80 Apr 29 12:30 org.chromium.Chromium.ImIP4v
drwx------  2 django django  80 Apr 29 12:30 org.chromium.Chromium.YL1S7L
drwx------  2 django django  80 Apr 29 12:30 org.chromium.Chromium.erkDSy
drwx------  2 django django  80 Apr 29 12:30 org.chromium.Chromium.orhmkv

They're pretty big too.

# du -sh /tmp/snap-private-tmp/snap.chromium/tmp/bun-chrome-80651/
4.0M    /tmp/snap-private-tmp/snap.chromium/tmp/bun-chrome-80651/
# du -sh /tmp/snap-private-tmp/snap.chromium/tmp/
21M /tmp/snap-private-tmp/snap.chromium/tmp/

Here, that bun-chrome-80651 was "only" 4MB. If you open a more busy web site, I've seen it become around 25MB.

I learned this the hard way because I server nearly died from exhausted disk usage since that directory was taking up ~4GB.

Now I have bash cron script that periodically deletes these files.

Comments

Your email will never ever be published.

Previous:
html-getter - A powerfully simple HTML scraper in Bun April 17, 2026 Bun, macOS, TypeScript
Related by category:
Bun vs. Go for a basic web server benchmark October 24, 2025 Bun
Benchmarking oxlint vs biome December 12, 2025 Bun, TypeScript
Testing out vite 8 on SPA: Vite 8 is 5x faster December 6, 2025 Bun, TypeScript
Hosting your static web site with Firebase Hosting November 3, 2025 Bun
Related by keyword:
Linux tip: du --max-depth=1 September 27, 2007 Linux
Find the largest node_modules directories with bash September 30, 2022 Linux, Bash, macOS
Find largest directories with du -k December 29, 2006 Linux