---
title: Bun v1.1.29
description: "Fixes 21 bugs (addressing 22 👍). Fixes issue with proxying requests with axios. N-API (napi) support in compiled C. Faster typed arrays in `bun:ffi` with 'buffer' type. Fixes issue with bundling imported .wasm files in `bun build`. Fixes regression with `bun build` from v1.1.28. Fixes snapshot regression in `bun test`. Fixes bug with argument validation in `Bun.build` plugins."
date: "2024-09-20T08:54:53.578Z"
author: jarred
---

Bun v1.1.29 is here! This release fixes 21 bugs (addressing 22 👍). Fixes issue with proxying requests with axios. N-API (napi) support in compiled C. Faster typed arrays in `bun:ffi` with 'buffer' type. Fixes issue with bundling imported .wasm files in `bun build`. Fixes regression with `bun build` from v1.1.28. Fixes snapshot regression in `bun test`. Fixes bug with argument validation in `Bun.build` plugins.

{% callout %}
We're hiring [systems engineers](/careers) in San Francisco to build the future of JavaScript!
{% /callout %}

#### 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
```

### N-API (napi) support in compiled C

In Bun v1.1.28 (previous version), we introduced support for [compiling and running C code from JavaScript](https://bun.sh/blog/compile-and-run-c-in-js).

In this release, we've added N-API (napi) support to `cc`. This makes it easier to return JavaScript strings, objects, arrays and other non-primitive values from C code.

For example, this returns a JavaScript string `"Hello, Napi!"`:

{% codetabs %}

```c#hello-napi.c
#include <node/node_api.h>

napi_value hello_napi(napi_env env) {
  napi_value result;
  napi_create_string_utf8(env, "Hello, Napi!", NAPI_AUTO_LENGTH, &result);
  return result;
}
```

```js#hello-napi.js
import { cc } from "bun:ffi";
import source from "./hello-napi.c" with {type: "file"};
const hello_napi = cc({
  source,
  symbols: {
    hello_napi: {
      args: ["napi_env"],
      returns: "napi_value",
    },
  },
});

console.log(hello_napi());
// => "Hello, Napi!"
```

{% /codetabs %}

You can continue to use types like `int`, `float`, `double` to send & receive primitive values from C code, but now you can also use N-API types! Also, this works when using `dlopen` to load shared libraries with `bun:ffi` (such as Rust or C++ libraries with C ABI exports).

### `"buffer"` type in bun:ffi

You can now use the `"buffer"` type in `bun:ffi` to send and receive JavaScript typed arrays (`Uint8Array`, `Buffer`, etc) in C code slightly faster and simpler.

The following example returns the last byte of a Uint8Array:

{% codetabs %}

```c#last-byte.c
uint8_t lastByte(uint8_t *arr, size_t len) {
  return arr[len - 1];
}
```

```js#last-byte.js
import { cc } from "bun:ffi";
import source from "./last-byte.c" with {type: "file"};
const lastByte = cc({
  source,
  symbols: {
    lastByte: {
      args: ["buffer", "usize"],
      returns: "u8",
    },
  },
});

const arr = new Uint8Array([1, 2, 3, 4, 5]);
console.log(lastByte(arr, arr.length));
// => 5
```

{% /codetabs %}

In this microbenchmark, the hash function gets **30% faster by using the `"buffer"` type** in `bun:ffi` instead of wrapping the Uint8Array in the `ptr()` function.

```sh
$ bun ./bench.js
cpu: Apple M3 Max
runtime: bun 1.1.29 (arm64-darwin)

benchmark          time (avg)             (min … max)       p75       p99      p995
----------------------------------------------------- -----------------------------
hash (ptr)      82.63 ns/iter   (79.6 ns … 172.82 ns)  81.65 ns 111.22 ns 118.77 ns
hash (buffer)   48.59 ns/iter    (45.04 ns … 94.9 ns)  50.09 ns  79.17 ns  81.93 ns
```

{% details summary="Benchmark code" %}

```js#bench.js
import { dlopen, ptr } from "bun:ffi";
import { bench, run } from "mitata";

const {
  symbols: { ffi_hash: hash },
} = dlopen(import.meta.dir + "/src/ffi_napi_bench.node", {
  ffi_hash: { args: ["ptr", "u32"], returns: "u32" },
});

const bytes = new Uint8Array(64);

const {
  symbols: { ffi_hash: hashBuffer },
} = dlopen(import.meta.dir + "/src/ffi_napi_bench.node", {
  ffi_hash: { args: ["buffer", "u32"], returns: "u32" },
});

bench("hash (ptr)", () => hash(ptr(bytes), bytes.byteLength));
bench("hash (buffer)", () => hashBuffer(bytes, bytes.byteLength));

await run();
```

{% /details %}

Under the hood, we've made the conversion between JavaScript typed arrays and C `uint8_t*` happen inline without external function calls, which makes it faster than using the `ptr` function from `bun:ffi`.

### Fixed: proxy with axios

A bug causing proxying requests with axios to not work properly is fixed.

Thanks to [@cirospaciari](https://github.com/cirospaciari) for the fix!

### Fixed: Bundling imported .wasm files in `bun build`

A bug that could cause a crash when bundling imported .wasm files in `bun build` is fixed.

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

### Fixed: regression with `bun build` from v1.1.28

A regression where certain symbols were being re-ordered incorrectly in `bun build` is fixed.

Thanks to [@paperclover](https://github.com/paperclover) for the fix!

### Fixed: snapshot regression in bun test

A regression that caused `bun test` to always update snapshots is fixed.

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

### Fixed: Argument validation issue in Bun.build plugins

A crash that could happen when passing an incorrect argument to the `plugins` option in `Bun.build` is fixed.

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

### Fixed: `cc` missing include directories on Linux and macOS

A bug that caused `cc` to not find the default system include directories on Linux and macOS is fixed.

### Thanks to 3 contributors!

- [@cirospaciari](https://github.com/cirospaciari)
- [@dylan-conway](https://github.com/dylan-conway)
- [@Jarred-Sumner](https://github.com/Jarred-Sumner)
