---
title: Bun v1.2.11
description: "Fixes 62 bugs (addressing 77 👍). `process.ref` and `process.unref`, `util.parseArgs` negative options, `BUN_INSPECT_PRELOAD`, Highway SIMD, Node.js compatibility improvements for `node:http`, `node:https`, `node:tls`, and `node:readline`"
date: "2025-04-29T02:39:42.691Z"
author: dylan
---

This release fixes 62 bugs (addressing 77 👍). It adds support for `process.ref` and `process.unref`, `util.parseArgs` negative options, `BUN_INSPECT_PRELOAD`, Highway SIMD, Node.js compatibility improvements for `node:http`, `node:https`, `node:crypto`, `node:tls`, and `node:readline`.

#### To install Bun

{% codetabs %}

```sh#curl
$ curl -fsSL https://bun.sh/install | bash
```

```sh#npm
$ npm install -g bun
```

```sh#powershell
$ powershell -c "irm bun.sh/install.ps1|iex"
```

```sh#scoop
$ scoop install bun
```

```sh#brew
$ brew tap oven-sh/bun
$ brew install bun
```

```sh#docker
$ docker pull oven/bun
$ docker run --rm --init --ulimit memlock=-1:-1 oven/bun
```

{% /codetabs %}

#### To upgrade Bun

```sh
$ bun upgrade
```

## `util.parseArgs` negative options and default arguments

This release adds support for negative options in `util.parseArgs` with `allowNegative`. This allows you to prefix options with `no-` for a false value.

```js
const { parseArgs } = require('util');
const args = parseArgs({
  args: ['--no-foo'],
  allowNegative: true,
  options: {
    foo: { type: 'boolean' },
  }
});
console.log(args.values.foo); // false
```

Also supported in this release: calling `parseArgs` without `args` will now default to `process.argv`.

```bash
$ bun -p \
      'require("util").parseArgs({options:{foo:{type:"boolean"}}}).values.foo' \
      -- --foo
true
```

Thanks to [@dylan-conway](https://github.com/dylan-conway)!

## Highway SIMD

Bun v1.2.11 adds Google's Highway SIMD library, shrinking the performance gap between baseline and non-baseline builds by selecting the best SIMD implementation at runtime. While adding the library, lexing inline sourcemaps in our JavaScript parser was refactored and is now ~40% faster.
<!-- https://github.com/oven-sh/bun/commit/0471254e4ea1231b2df38df8a95b1998d9770fbb -->

## Preload with `BUN_INSPECT_PRELOAD`

Bun now supports using the `BUN_INSPECT_PRELOAD` environment variable as an equivalent to the `--preload` flag. This allows you to specify a file to be preloaded before running a script.

```js
$ BUN_INSPECT_PRELOAD=./setup.js bun run index.js
// Same as:
$ bun --preload ./setup.js run index.js
```

Thanks to [@zackradisic](https://github.com/zackradisic)!
<!-- https://github.com/oven-sh/bun/commit/ce8cae060d80d27b608737e2f09f47029db523b3 -->

## DevServer reliability improvements

Fixed multiple DevServer crashes related to source map handling and event processing. New stress testing has been added to ensure future reliability.

Thanks to [@paperclover](https://github.com/paperclover)!
<!-- https://github.com/oven-sh/bun/commit/be65720f71f75939ad29a1a027ee757547c36af1 -->

## Support `process.ref` and `process.unref`

Bun now supports `process.ref()` and `process.unref()` methods, which provide a standardized way to control whether objects prevent the event loop from exiting.

```js
const customTimer = {
  ref() { },
  unref() { }
};

process.ref(customTimer);   // Calls customTimer.ref()
process.unref(customTimer); // Calls customTimer.unref()

// Also works with symbols
const symbolTimer = {
  [Symbol.for('nodejs.ref')]() { },
  [Symbol.for('nodejs.unref')]() { }
};

process.ref(symbolTimer);
process.unref(symbolTimer);

// And with native timers
const interval = setInterval(() => {}, 1000);
process.unref(interval);
process.ref(interval);
```

Thanks to [@dylan-conway](https://github.com/dylan-conway) for the contribution!
<!-- https://github.com/oven-sh/bun/commit/33d656eebe13ee04ed5b8478b360bb1a5c1bd4b2 -->

## Fixed `require.extensions` index out of bounds

An edge case in `require.extensions` handling that could lead to an "index out of bounds" crash has been fixed. This issue could occur when assigning and removing multiple custom extension handlers. The fix can be seen [here](https://github.com/oven-sh/bun/pull/19231).

Thanks to [@paperclover](https://github.com/paperclover)!
<!-- https://github.com/oven-sh/bun/commit/80aff249510764e51d2e629527e138dbfa84e166 -->

## `node:crypto` compatibility improvements

Bun v1.2.11 improves `node:crypto` by reimplementing the full `KeyObject` class hierarchy (`SecretKeyObject`, `PublicKeyObject`, `PrivateKeyObject`) and adding `structuredClone` support for both `KeyObject` and `CryptoKey` class instances.

```js
const secretKey = crypto.generateKeySync("aes", { length: 128 });
const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", { modulusLength: 2048 });

// Keys are now clonable
const secretKeyClone = structuredClone(secretKey);
const publicKeyClone = structuredClone(publicKey);
const privateKeyClone = structuredClone(privateKey);

console.log(
  publicKey.equals(publicKeyClone),   // true
  privateKey.equals(privateKeyClone), // true
  secretKey.equals(secretKeyClone),   // true
);

console.log(
    publicKey.constructor.name,  // PublicKeyObjet
    privateKey.constructor.name, // PrivateKeyObject
    secretKey.constructor.name,  // SecretKeyObject
);
```

Thanks to [@dylan-conway](https://github.com/dylan-conway)!

## `crypto.generatePrime(Sync)` return type fix

The `crypto.generatePrime` and `crypto.generatePrimeSync` functions now correctly return `ArrayBuffer` instead of `Buffer`.

```js
const prime = crypto.generatePrimeSync(512);
console.log(prime instanceof ArrayBuffer); // true
```

Thanks to [@dylan-conway](https://github.com/dylan-conway) for the contribution!
<!-- https://github.com/oven-sh/bun/commit/7e8e559fce01a5ff8d99e777abf4a95cc4f9f46d -->

## Fix boolean check in `node:https` `createServer`

Fixed a compatibility issue with `node:https` where the `rejectUnauthorized` option was not properly validated as a boolean.

```js
// This code will now properly validate boolean options
const https = require('https');
const server = https.createServer({
  key: key,
  cert: cert,
  rejectUnauthorized: "not a boolean" // Will throw a TypeError
});
```

Thanks to [@alii](https://github.com/alii)!
<!-- https://github.com/oven-sh/bun/commit/9f0ba159950281b24f516f1bf5c0ffa42413e8b5 -->

## Fix `node:readline/promises` error handling

Fixed an issue with error handling in `node:readline/promises`. The fix properly rejects promises when errors occur during readline operations.

```js
// Before, errors could be silently ignored
const readline = new Readline(writable);
await readline.clearLine(0).commit(); // Could silently fail

// Now errors are properly propagated
try {
  await readline.clearLine(0).commit();
} catch (err) {
  console.error(err);
}
```

Thanks to [@alii](https://github.com/alii) for the contribution!
<!-- https://github.com/oven-sh/bun/commit/c97bbe6428f5d50f2a2dd96179209cb7d5dcee86 -->

## TypeScript improvements for `Bun.$`

The `Bun.$` shell API can now be used as a type, allowing for better TypeScript integration when working with shell instances.

```js
class Wrapper {
  shell: Bun.$; // Bun.$ is now available as a type
  constructor() {
    this.shell = Bun.$.nothrow();
  }
}
```

Thanks to [@alii](https://github.com/alii) for the contribution!
<!-- https://github.com/oven-sh/bun/commit/98c66605e51f7cc048fb060207044afd0be6fdc6 -->

## Fix for PostgreSQL flush method

Fixed an issue where the `flush()` method on PostgreSQL connections was undefined. The method is now properly implemented and works as expected.

```js
await sql`SELECT * FROM users WHERE id = ${userId}`;
sql.flush(); // Works correctly now
```

Thanks to [@cirospaciari](https://github.com/cirospaciari) for the contribution!
<!-- https://github.com/oven-sh/bun/commit/a512ad515586643fdd10dcbec51eda3495543be8 -->

## Fixed type validation in HTTP/2 client options

The HTTP/2 client request method now properly validates option parameters, throwing appropriate type errors when incorrect values are provided for `endStream`, `weight`, `parent`, `exclusive`, and `silent` options.

```js
// This will now properly throw a type error
const client = http2.connect(`http://localhost:${port}`);
client.request({
  ':method': 'GET',
  ':path': '/'
}, {
  silent: "yes",  // Error: options.silent must be a boolean
  weight: "high"  // Error: options.weight must be a number
});
```

Thanks to [@alii](https://github.com/alii) for the contribution!
<!-- https://github.com/oven-sh/bun/commit/316cc204567efec2dc493f39587c49dc3eb7fed1 -->

## Fixed HTTP/2 client port stringification

Fixed an issue in the HTTP/2 client implementation where ports were not stringified correctly. 

```js
const connect = net.connect;
net.connect = (...args) => {
  console.log(args[0].port === '80'); // true
  return connect(...args);
}
const client = http2.connect('http://localhost:80');
```

Thanks to [@alii](https://github.com/alii) for the contribution!
<!-- https://github.com/oven-sh/bun/commit/e6c516465e371c8a7689137aca0ebdcb0e58e4cb -->

## Fix dead code elimination for unused calls in comma expressions

Bun now correctly eliminates unused function calls inside comma expressions during minification when the functions are pure. In the previous version, this could cause syntax errors for valid code.

```js
const result = (/* @__PURE__ */ funcWithNoSideEffects(), 456);

// Output was previously incorrectly transformed into:
const result = ( , 456);
```

Thanks to [@paperclover](https://github.com/paperclover)!
<!-- https://github.com/oven-sh/bun/commit/5cc34b667c5ca69bf2ed1e25e4919e3f23acfb11 -->

## Fixed `queueMicrotask` error handling

Error handling in `queueMicrotask` has been improved. When passing an invalid argument (like `null`) it now throws an error with code `ERR_INVALID_ARG_TYPE` matching Node.js behavior.

```js
queueMicrotask(null);
```

Thanks to [@dylan-conway](https://github.com/dylan-conway)!
<!-- https://github.com/oven-sh/bun/commit/83a2a649651d78a1130e6a3c677beb0692628354 -->

## Fixed typo in `ReadableStream.prototype.tee` 

Fixed a bug in the implementation of `ReadableStream.prototype.tee()` where a typo in the property name (`fllags` instead of `flags`) could cause incorrect behavior when checking for canceled stream states.

```js-diff
- if (teeState.fllags & (TeeStateFlags.canceled1 | TeeStateFlags.canceled2))
+ if (teeState.flags & (TeeStateFlags.canceled1 | TeeStateFlags.canceled2))
```
<!-- https://github.com/oven-sh/bun/commit/27a5712ed383a7ec167cf26f498f9962c172ad92 -->

## Fixed crash in `Bun.plugin`

Fixed an issue where using `Bun.plugin` in certain scenarios (particularly with recursive plugin calls) could crash. Proper exception handling has been added to prevent crashes when plugins encounter errors.

```js
Bun.plugin({
  name: "recursion",
  setup(builder) {
    builder.onResolve({ filter: /.*/, namespace: "recursion" }, ({ path }) => ({
      path: require.resolve("recursion:" + path),
      namespace: "recursion",
    }));
  },
});
```

## Fixed TLSSocket `allowHalfOpen` behavior

Bun now correctly matches Node.js behavior for the `allowHalfOpen` property in `TLSSocket`. When a socket is passed to the `TLSSocket` constructor that is either a `net.Socket` or a `stream.Duplex`, the `allowHalfOpen` option is now properly ignored and set to `false`, regardless of the value specified in options.

```js
const socket = new tls.TLSSocket(new net.Socket(), { allowHalfOpen: true });
console.log(socket.allowHalfOpen); // false

const customSocket = new tls.TLSSocket(undefined, { allowHalfOpen: true });
console.log(customSocket.allowHalfOpen); // false
```

Thanks to [@alii](https://github.com/alii) for the contribution!
<!-- https://github.com/oven-sh/bun/commit/f5fdd02237f69e7cef450d759c7d72bdfe4a119e -->

## Thanks to 14 contributors!

- [@190n](https://github.com/190n)
- [@alii](https://github.com/alii)
- [@cirospaciari](https://github.com/cirospaciari)
- [@dylan-conway](https://github.com/dylan-conway)
- [@eckhardt-d](https://github.com/eckhardt-d)
- [@electroid](https://github.com/electroid)
- [@heimskr](https://github.com/heimskr)
- [@jarred-sumner](https://github.com/jarred-sumner)
- [@mastermakrela](https://github.com/mastermakrela)
- [@nektro](https://github.com/nektro)
- [@paperclover](https://github.com/paperclover)
- [@pfgithub](https://github.com/pfgithub)
- [@x04](https://github.com/x04)
- [@zackradisic](https://github.com/zackradisic)