Bun Release Notes: Performance, Streaming, and Developer Experience Enhancements

development tools

This Bun release introduces Web-standard CompressionStream/DecompressionStream, enhanced build controls, `bun:test` retry/repeats, SQLite 3.51.0, and numerous bug fixes for improved stability and developer experience.

This release addresses 95 issues, delivering significant improvements and new features across the Bun ecosystem.

Installation

To install Bun, choose your preferred method:

  • cURL:
    curl -fsSL https://bun.sh/install | bash
    
  • npm:
    npm install -g bun
    
  • PowerShell:
    powershell -c "irm bun.sh/install.ps1|iex"
    
  • Scoop:
    scoop install bun
    
  • Homebrew:
    brew tap oven-sh/bun
    brew install bun
    
  • Docker:
    docker pull oven/bun
    docker run --rm --init --ulimit memlock=-1:-1 oven/bun
    

Upgrading Bun

To upgrade Bun to the latest version, simply run:

bun upgrade

New Features & Enhancements

CompressionStream and DecompressionStream

Bun now natively supports the Web-standard CompressionStream and DecompressionStream APIs. These allow for efficient, streaming compression and decompression of data without requiring the entire payload to be buffered in memory.

In addition to the standard "gzip", "deflate", and "deflate-raw" formats, Bun also supports "brotli" and "zstd".

const response = await fetch("https://example.com");

// Compress the response body using gzip
const compressed = response.body.pipeThrough(new CompressionStream("gzip"));

// Or use zstd for faster compression
const zstd = response.body.pipeThrough(new CompressionStream("zstd"));

Control .env and bunfig.toml Loading in Standalone Executables

Standalone executables built with bun build --compile typically search for .env and bunfig.toml files in their execution directory. You can now disable this behavior at build time using the --no-compile-autoload-dotenv and --no-compile-autoload-bunfig flags.

This ensures deterministic executable behavior, independent of configuration files in the user's working directory.

# Disable .env and bunfig.toml loading
bun build --compile --no-compile-autoload-dotenv --no-compile-autoload-bunfig app.ts

This can also be configured via the JavaScript API:

await Bun.build({
  entrypoints: [
    "./app.ts"
  ],
  compile: {
    // Disable .env loading
    autoloadDotenv: false,
    // Disable bunfig.toml loading
    autoloadBunfig: false,
  },
});

retry and repeats in bun:test

The bun:test module now supports retry and repeats options for more robust test management:

  • retry: Reruns a test callback up to a specified number of times. The test passes if any single run succeeds, useful for handling flaky tests.
  • repeats: Executes a test callback a specified number of times. The test fails if any single run fails, useful for ensuring test stability.
import { test } from "bun:test";

test("flaky test", () => {
  if (Math.random() > 0.1) throw new Error("fail");
}, { retry: 3 });

test("check for flakiness", () => {
  // run this 20 times to ensure it's stable
}, { repeats: 20 });

--no-env-file Flag

You can now disable Bun's automatic .env file loading using the --no-env-file flag. This is particularly useful in production or CI/CD environments where reliance on system environment variables is preferred.

bun run --no-env-file index.ts

This behavior can also be configured in bunfig.toml:

# Disable loading .env files
env = false

Note that environment files explicitly provided via --env-file will still be loaded, even when default loading is disabled.

SQLite 3.51.0 Update

The bun:sqlite module has been updated to SQLite version 3.51.0.

import { Database } from "bun:sqlite";

const db = new Database();
console.log(db.prepare("SELECT sqlite_version()").get());
// { "sqlite_version()": "3.51.0" }

Internal: Upgraded to Zig 0.15.2

Bun is now built with Zig 0.15.2, resulting in a 0.8MB reduction in binary size and improved build times for contributors.

Bug Fixes and Improvements

Bundler

  • Resolved a rare panic in the dev server when processing CSS assets in the incremental graph.
  • Fixed a rare panic in the dev server that could occur if a file referenced by a dynamic import was deleted during a reload.

bun install

  • Addressed a rare crash during bun install related to optional peer dependencies.
  • Fixed a regression in bun install when parsing git dependency URLs with a leading hash.
  • Corrected a regression from Bun v1.3.2 that caused bun ls --all to crash with unresolved optional peer dependencies.
  • Resolved a regression from Bun v1.3.2 where sharp versions older than v0.33.0 failed to install correctly.

Windows

  • process.stdout now emits 'resize' events and SIGWINCH signals, fixing terminal resizing issues in Claude Code & OpenCode.
  • Improved bun getcompletes functionality on Windows.
  • Fixed a crash on Windows that occurred when a laptop hibernated and resumed execution after a Worker thread had been terminated.

Node.js Compatibility

  • Implemented _handle.fd in node:net and node:tls for enhanced compatibility with libraries relying on socket file descriptors.
  • Fixed an N-API bug that prevented rspack or rsbuild from working.

Web APIs

  • Resolved a fuzzer-discovered crash when using JSON.stringify on a FormData object in rare cases.
  • Fixed a fuzzer-discovered crash when calling stream on a Blob in certain edge cases.
  • Addressed a sanitizer-discovered memory leak in Blob.

Bun.serve

  • Fixed an issue where Unicode characters in Bun.serve static Response objects (given a string input) were missing the Content-Type header.

Networking

  • Resolved a sanitizer-discovered memory leak in node:net.SocketAddress when passing an invalid port.
  • Fixed a sanitizer-discovered memory leak in Bun.listen when errors were thrown during socket creation.

YAML

  • Bun.YAML.stringify no longer incorrectly serializes strings with leading zeros as numbers.
  • Fixed a performance issue where YAML merge keys could cause parsing to hang due to exponential complexity.

Transpiler

  • Resolved a fuzzer-discovered crash in new Bun.Transpiler() with invalid configuration.

Bun.spawn

  • Fixed a small memory leak in Bun.spawn when passing extra non-IPC, non-stdout, non-stderr, and non-stdin file descriptors.

TypeScript Definitions

  • Added JSDoc documentation for configVersion in the BunLockFile type definition.
  • Added missing "css", "jsonc", "yaml", and "html" to the Loader type definition.
  • Removed unnecessary dependency on @types/react in @types/bun.

Security

  • Updated root certificates to Mozilla NSS 3.117.

bun upgrade

  • bun upgrade now displays download sizes in human-readable units (e.g., 23.2MiB) instead of raw bytes.