Running our whole stack on Bun 1.4
Our backend services, all seven Next.js apps, their tests and our CI now run on Bun 1.4.2, and Node is gone from the stack. Here's what changed in 1.4, the measurements behind the move, and the platform details that mattered along the way.
Earlier this year we moved our six NestJS backend services to Bun. Anvil is our observability tool for Control4 driver developers, and those services run its GraphQL and internal APIs, MQTT ingestion, queued work, webhooks and an MCP server. That move came with two compromises. The backends were pinned to Bun 1.3.14 with workarounds for socket behaviour that version got wrong. And our Next.js frontends stayed on Node 24, because Next under Bun built more slowly and served worse tail latency.
Bun 1.4 changed both. Today a single Bun version, 1.4.2, runs everything:
- Backends on 1.4.2. On the same machine, the webhooks service serves about 45 percent more requests per second than on 1.3.14, with half the p99 latency, and a nine-hour soak held steady.
- Graceful shutdown is back. A one-line fix to Apollo Server's connection drain replaces the workaround that removed it.
- All seven Next.js apps build and serve on Bun. Serving was faster on every path we measured, and build times matched Node.
- Tests run on Bun. Thirteen Jest projects moved to
bun test, and our Playwright end-to-end suite runs on Bun with one small patch. - No Node anywhere. Every container image builds from Bun 1.4.2, CI no longer installs Node, and developer machines pin the version in
.bun-version.
There's one trade-off we're watching: under sustained server rendering, Bun's memory didn't fall back after the load stopped, where Node's did. The numbers are below.
What 1.4 fixed underneath us
The biggest change in 1.4 is invisible from application code. Bun 1.3.14's node:http never told server-side sockets they had closed: the operating system released the connection, but the JavaScript close event never fired. Anything that cleaned up on close kept a reference to every connection it had ever seen. In 1.4, server connections are real net.Socket objects, and close fires when the TCP connection ends.
We checked that before anything else. Under an hour of fresh connections at about 20 a second, with keep-alive off, a NestJS and Apollo test server on 1.4.2 held steady: resident memory rose from 127.6 MB to 132.9 MB, levelling off within ten minutes, against a Node 24 control that rose from 146.2 MB to 150.0 MB. Retained sockets and requests stayed at zero throughout.
A plain HTTP server that is also an https.Server
With close fixed, we expected to undo our 1.3.14 workaround and switch Apollo Server's HTTP drain plugin back on. The plugin is what lets a server stop accepting connections and finish in-flight requests when Kubernetes shuts a pod down. Switched back on, though, it still grew by about 100 MB an hour under connection churn.
The cause is a detail of how Bun implements Node's HTTP modules. On Bun, http.Server and https.Server are the same class:
| Check | Node 24 | Bun 1.3.14 | Bun 1.4.2 |
|---|---|---|---|
http.Server === https.Server | false | true | true |
http.createServer() instanceof https.Server | false | true | true |
Apollo's drain helper chooses which server event to watch for new connections with exactly that check:
server.on(
server instanceof https.Server ? 'secureConnection' : 'connection',
(socket) => {
this.requestCountPerSocket.set(socket, 0);
socket.once('close', () => this.requestCountPerSocket.delete(socket));
},
);
Our services serve plain HTTP behind a proxy that terminates TLS, so on Node this picks connection. On Bun, the plain HTTP server passes the https.Server check, the helper waits for secureConnection instead, and that event never comes. The cleanup is never attached, and the helper keeps one entry per connection forever. After a minute of churn it held 1,114 entries, though 1,101 of those sockets had already closed.
On 1.3.14 this was hidden behind the missing close event, which broke the same cleanup in a different way. With that fixed in 1.4, it was the only fault left.
The fix is one line in a patched copy of @apollo/server: watch both connection and secureConnection. That's correct on any runtime, and with it the helper's map drained to zero and memory stayed level over the same churn. The drain plugin is back on, so a pod that's shutting down finishes its requests before it exits.
Update, October 2026: Bun 1.4.4 makes https.Server a separate class, so a plain HTTP server no longer passes the instanceof https.Server check (oven-sh/bun#41781). The change wasn't called out in the release notes. In 1.4.4 https.Server inherits from http.Server, which differs from Node and has its own open issue (oven-sh/bun#46567), but it doesn't affect a plain HTTP server like ours. Our patch, which watches both events, stays correct either way.
Backend numbers
We qualified 1.4.2 against real services: ingestion, the worker and webhooks running from TypeScript source, with private Mosquitto and Valkey instances and our telemetry simulator as load.
Throughput. Two webhooks instances built from the same source ran side by side on the same machine, one on each Bun version, measured with autocannon at 50 connections:
| Round | Bun | Requests/s | p50 | p99 |
|---|---|---|---|---|
| 1 | 1.4.2 | 13,153 | 2 ms | 17 ms |
| 1 | 1.3.14 | 8,120 | 4 ms | 33 ms |
| 2 | 1.4.2 | 11,725 | 3 ms | 24 ms |
| 2 | 1.3.14 | 8,587 | 4 ms | 32 ms |
That's on top of the gain 1.3.14 already had over Node. These absolute numbers come from a different machine and endpoint from the ones in our first post, so the pairing within this table is the comparison that counts.
Outages. We stopped Redis for 30 seconds, then the MQTT broker for 30 seconds, under steady load. Ingestion and the worker carried on at the same rate through both, with no failed or stuck jobs.
Soak. Over nine hours of load, about 108,000 errors over HTTP throughout and 262,000 events over MQTT in roughly four of those hours, every service's memory stayed in a steady band. The worker ended at 277 MB and webhooks at 163 MB, and the ingestion roles held between 135 and 207 MB.
Next.js without Node
Our first post found Next.js builds hanging under Bun. Next passes its own runtime flags to a CSS worker it starts through NODE_OPTIONS; under Bun that included --bun, which Node rejects, so the worker died and the build waited forever.
That problem disappears once there's no Node binary at all. When the command that runs Next resolves node to Bun itself, as it does under bun --bun run and in an image with no Node installed, the worker starts under Bun too, and the build completes. It does still happen if you start a script with bun --bun file.js on a machine that also has Node, so our images and scripts always go through bun --bun run.
With that, all seven of our Next.js apps build with no Node on the path, and next dev works too. We measured Next 16.3.5 on Bun 1.4.2 against Node 24 on our main dashboard app, alternating rounds on a developer machine:
| Measure | Bun 1.4.2 against Node 24 |
|---|---|
| Production build | about the same, between 25 and 45 seconds on both |
| API route throughput | between 1.4 and 1.8 times Node |
| Server-rendered page throughput | between 1.05 and 1.9 times Node, with lower p99 |
| Memory at start | about 60 MB lower |
The trade-off is memory under sustained rendering. Over a nine-minute rendering soak, Bun's resident memory moved between 540 and 655 MB and stayed there after the load stopped. Node peaked at about 700 MB but fell back to 239 MB once idle. Bun's peak is lower; it just doesn't hand memory back as readily.
Tests on Bun
Thirteen Jest projects moved to bun test, keeping their per-file Node or jsdom environments, setup files, JUnit output and coverage.
Playwright needs one patch. On Bun, Playwright registers its TypeScript loader by setting Module._extensions['.ts'] to the JavaScript loader, so test files written in TypeScript are parsed as plain JavaScript and fail with errors like N errors building. A one-line guard in Playwright's installTransformIfNeeded skips that assignment when it's running on Bun, and the whole end-to-end suite then runs under Bun.
bun test --isolate occasionally crashes in CI. Isolate mode gives each test file its own JavaScript realm and tears it down afterwards, which is exactly when cross-realm finalizers run. On our CI machines that path crashed the runtime a few times: two segmentation faults in garbage-collection finalization, and once a FinalizationRegistry callback running without its this. Forty runs of the same image locally produced none, so we couldn't narrow it further. Our test wrapper now re-runs bun test once when the runtime itself is killed by a signal. A crash leaves no test verdict, so re-running isn't the same as retrying a flaky test, which our pipeline still refuses to do. Production services don't create realms, and the nine-hour soak on the same binary had none of this.
One runtime, one version
Every container image now builds from Bun 1.4.2. CI runs scripts and build targets with Bun and no longer installs Node, and a check enforces that. Developer machines read the version from .bun-version, so local runs, tests, CI and production all use the same runtime.
That leaves a short list we maintain: the Apollo drain patch and the Playwright patch, both checked by specs when dependencies update, the test wrapper's re-run, and keeping an eye on rendering memory as traffic grows.