AI 编程 4.0 · 优秀 2026-08-20 · 文章

Research: A shot-scraper-style JSON API on Bun 1.4's new Bun.WebView

Bun 1.4 是 Rust 重写后的首个稳定版:+1,517 个 Node 测试修复 2,900+ 问题空闲 CPU 降 5 倍内存最高省 35%Linux 启动快 50%Willison 最关注 Bun.WebView把浏览器自动化做进 runtime 本身,macOS 走 WebKit其他平台经 CDP 控本地 Chromium他用 Claude Code 写了约 150 行零依赖 TypeScript,做出 shot-scraper 风格的 JSON API:/javascript 对页面执行 JS/screenshot 出 PNG/JPEG/WebP 截图/healthz 健康检查,每请求开一个 tab 支持并发...

打开原文回到归档

Research: A shot-scraper-style JSON API on Bun 1.4's new Bun.WebView

中文导读

Bun 1.4 是 Rust 重写后的首个稳定版:+1,517 个 Node 测试、修复 2,900+ 问题、空闲 CPU 降 5 倍、内存最高省 35%、Linux 启动快 50%。Willison 最关注 Bun.WebView——把浏览器自动化做进 runtime 本身,macOS 走 WebKit、其他平台经 CDP 控本地 Chromium。他用 Claude Code 写了约 150 行零依赖 TypeScript,做出 shot-scraper 风格的 JSON API:/javascript 对页面执行 JS、/screenshot 出 PNG/JPEG/WebP 截图、/healthz 健康检查,每请求开一个 tab 支持并发;cgroups 实测跑完整 Chrome 处理复杂网页只需 192–256MB 容器,全程不需要 Puppeteer 或 Playwright。

为什么值得关注

给 agent/爬虫场景提供“runtime 原生浏览器”的新选项:省掉一整层 Puppeteer/Playwright 依赖,内存占用可控在约 200MB 级,适合做成可并发的截图/JS 执行微服务;对评估 Bun 生产可用性的人,这份 release 数字(Node 兼容性、CPU/内存/启动)也是一手材料。

关键信息

  • Bun 1.4(2026-08-20 发布):Rust 重写后首个稳定版
  • 数字:+1,517 Node 测试 / 2,900+ 修复 / 空闲 CPU 降 5x / 内存最高省 35% / Linux 启动快 50%
  • Bun.WebView:macOS 用 WebKit,其他平台 CDP 控本地 Chromium
  • 原型:约 150 行 TS、零依赖;端点 /javascript /screenshot /healthz;每请求一个 tab,支持并发
  • 资源:cgroups 实测 192–256MB 容器内跑完整 Chrome 处理复杂网页
  • 代码:github.com/simonw/research(bun-webview-json-api)

English Summary

Bun 1.4, the first stable release since the Rust rewrite, adds +1,517 Node.js tests, 2,900+ fixes, 5x lower idle CPU, up to 35% memory savings and 50% faster Linux startup. Bun.WebView brings browser automation into the runtime via macOS WebKit or CDP control of a local Chromium. Willison used Claude Code to build a ~150-line zero-dependency TypeScript service exposing a shot-scraper-style JSON API (/javascript, /screenshot, /healthz), one tab per request with concurrency; cgroups testing shows a full Chrome against complex pages fits in a 192-256MB container, with no Puppeteer or Playwright.

原文要点摘录

A zero-dependency, roughly 150-line TypeScript service demonstrates that Bun 1.4's experimental Bun.WebView can provide a shot-scraper-style JSON API for JavaScript evaluation and PNG/JPEG/WebP screenshots without Puppeteer or Playwright.
Bun 1.4 adds +1,517 tests from the Node.js test suite - our biggest jump in Node.js compatibility since Bun 1.0. Bun v1.4 also fixes over 2,900 issues. It reduces idle CPU usage by 5x, reduces memory usage by up to 35%, and starts 50% faster on Linux.
which appears to need a 192MB-256MB container to run a full Chrome against complex web pages - tested using cgroups.

Obsidian Notes

  • 内容由 opencli web read 抓取 simonwillison.net 原文生成(2026-08-23)。
  • 候选来源:AK-RSS Digest 2026-08-23(评分 7.8);性能数字与内存实测均锚定原文与 Bun 官方 release note 引用。