Bun

Bun v1.1.45


Jarred Sumner ยท January 17, 2025

We're hiring systems engineers in San Francisco to build the future of JavaScript!

This release fixes 13 bugs (addressing 50 ๐Ÿ‘) and improves compatibility with Node.js. 82% of the 'streams' module tests from Node.js' test suite now pass in Bun. node:crypto now implements diffieHellman, getCipherInfo, and X509Certificate. The checkServerIdentity object now matches Node.js' format. Bugfixes in Bun's fs.mkdirSync method, importing with query strings.

To install Bun

curl
npm
powershell
scoop
brew
docker
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
brew
brew tap oven-sh/bun
brew install bun
docker
docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun

To upgrade Bun

bun upgrade

node:stream compatibility improvements

node:stream now passes 82% of Node.js' test suite. Several of the remaining test failures are testing Node.js internals that don't exist in Bun.

Thanks to @nektro for this!

node:crypto improvements

X509Certificate

This release implements X509Certificate in node:crypto.

import { X509Certificate } from "node:crypto";

// Create a new X.509 certificate from a string
const cert = new X509Certificate(
  "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----",
);

// Get the subject of the certificate
console.log(cert.subject); // Outputs the subject's distinguished name

Thanks to @dylan-conway for this! And thanks to @jasnell for the ncrypt wrapper library used by Bun, Cloudflare Workers, and Node.js.

diffieHellman

The diffieHellman method is now implemented in node:crypto.

getCipherInfo

The getCipherInfo method is now implemented in node:crypto.

Certificate

The Certificate class with static methods exportPublicKey, exportChallenge, and verifySpkac is now implemented in node:crypto.

checkServerIdentity fix

The X509 object returned by checkServerIdentity (used in node:http, node:tls, and also in fetch) now matches the format of the X509 object in Node.js. Some fields were strings in Bun and arrays of strings in Node.js, now they're arrays of strings in Bun as well.

Fixed: memory leak involving X509 certificates in node:tls

A memory leak involving X509 certificates in node:tls has been fixed.

Fixed: fs.mkdir recursive regression

A regression introduced in Bun v1.1.44 (while working on node:fs compatibility) caused fs.mkdirSync to throw an error when the target directory already exists. This commit fixes the regression.

it("fs.mkdirSync recursive should not error when the directory already exists, but should error when its a file", () => {
  expect(() =>
    mkdirSync(import.meta.dir, { recursive: true }),
  ).not.toThrowError();
  expect(() => mkdirSync(import.meta.path, { recursive: true })).toThrowError();
});

Fixed: hang when importing duplicate modules with ?query strings

A regression introduced in Bun v1.1.21 caused Bun to hang when importing modules with query strings in the URL. This commit fixes the regression.

// This used to hang
import myModule from "./myModule.js";
import myModule2 from "./myModule.js?param=value";

// This did not hang
import myModule3 from "./myModule.js?param=value";
import myModule4 from "./myModule.js";

Thanks to 5 contributors!