---
title: Bun v0.5.7
description: Support for `FormData` and `git` dependencies, better `setTimeout()` compatibility, `bun wiptest` is now `bun test`, and better support on AWS Lambda and GitHub Actions.
date: "2023-02-24T00:00:50+00:00"
author: ashcon
thumbText: v0.5.7
---

Bun v0.5.7 introduces `FormData` support, `git` dependencies, and `AbortSignal` with `fetch()`, `setTimeout()` is now more compatible with Node.js, `bun wiptest` is now `bun test` — with pretty-printed diffs! — and improved support on AWS Lambda and GitHub Actions.

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

# Install using npm
# npm install -g bun

# Upgrade
bun upgrade
```

## `FormData` support

Bun now supports [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData), a standard Web API for working with form fields and files in multipart uploads. You can add a `string` as a field or a `Blob` as a file.

```ts
const formData = new FormData();
formData.set("attachment-id", crypto.randomUUID());
formData.set("attachment", Bun.file("./package.json"));
const response = await fetch("https://example.com/upload", {
  method: "POST",
  body: formData,
});
```

You can also parse `FormData` from a `Request` or `Response`.

```ts
export default {
  async fetch(request: Request): Promise<Response> {
    const formData = await request.formData();
    const file = formData.get("attachment");
    // ...
    return new Response(file);
  },
};
```

In Bun, [`response.formData()`](https://developer.mozilla.org/en-US/docs/Web/API/Response/formData) runs:

- **25x** faster than Node v19.6.0
- **4x** faster than Deno v1.30.3

{% image  width="100%" alt="image" src="https://user-images.githubusercontent.com/709451/220815500-39575f67-c3a6-4217-87e9-e74217103e64.png" /%}

[View benchmark](https://github.com/oven-sh/bun/blob/24d624b176df241936d4ec82b2d6f93861de6229/bench/snippets/form-data.mjs#L1)

## Git dependencies

Bun now supports `git` dependencies in `package.json`. Bun accepts a variety of git dependency formats, including [`github`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#github-urls), [`git`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#git-urls-as-dependencies), `git+ssh`, `git+https`, and many more.

```json
{
  "dependencies": {
    "zod": "github:colinhacks/zod",
    "lodash": "git@github.com:lodash/lodash.git#4.17.21"
  }
}
```

You can also add a `git` dependency using `bun install`.

```sh
bun install git@github.com:moment/moment.git
```

## Changes to `setTimeout()`

The Web standard [`setTimeout()`](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout) returns a `number`, which represents a timeout ID. The Node.js implementation of [`setTimeout()`](https://nodejs.org/api/timers.html#cleartimeouttimeout) returns a `Timeout` object, which has methods like `ref()` and `unref()`, but is coercable to a `number`.

We (reluctantly) decided to change Bun's implementation to match Node.js because there are many `npm` packages that depend on this legacy behaviour.

```ts
const timeout = setTimeout(() => {
  process.abort(); // this is not called, see `unref()` below
}, 1000);

timeout.unref();

// For compatibility, it still works as a number
const timeoutId = +timeout; // 1
```

We also improved the `console.log()` formatting of the `Timeout` object.

{% image  width="456" alt="image" src="https://user-images.githubusercontent.com/709451/220816678-03ce091d-2e5b-47a8-8d0f-9bb15b561d3b.png" /%}

## `AbortSignal` with `fetch()`

You can now cancel a [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) request using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). This is useful for timeouts or when you need to cancel a request before a response is received.

```ts
await fetch("https://example.com", {
  // Abort if the response is not received after 1 second
  signal: AbortSignal.timeout(1000),
});
```

You can also use an `AbortSignal` when receiving a `Request` from the HTTP server.

```ts
export default {
  async fetch(request: Request): Promise<Response> {
    request.signal.addEventListener("abort", () => {
      console.log("Client aborted the request");
    });
    // ...
    return new Response();
  },
};
```

## `bun wiptest` is now `bun test`

It's time for `bun wiptest` to graduate to `bun test`.

### Pretty-printed diffs

`bun test` now supports pretty-printed diffs, thanks to [@dylan-conway](https://github.com/dylan-conway) for implementing and @SuperAuguste for porting the [diff-match-patch](https://github.com/google/diff-match-patch) algorithm to Zig.

**Now:**

```ts
error: expect(received).toEqual(expected)

  {
    abc: 123,
+   def: 456
-   def: 789
  }

- Expected  - 1
+ Received  + 1
```

**Before:**

```ts
error: Expected values to be equal:
	Expected: {
  abc: 123,
  def: 789
}
	Received: {
  abc: 123,
  def: 456
}
```

### Auto-import for `jest` globals

`bun test` now automatically imports [`test()`](https://jestjs.io/docs/api#testname-fn-timeout) and [`expect()`](https://jestjs.io/docs/expect#expectvalue). This also works for the other Jest globals, including: `describe`, `beforeAll`, `afterAll`, and more.

```ts
// import { test, expect } from "bun:test";

test("that it auto-imports expect()", () => {
  expect({
    abc: 123,
    def: 456,
  }).toEqual({
    abc: 123,
    def: 789,
  });
});
```

We still recommended that you import from `bun:test`, but if you have existing tests using Jest, you probably rely on its globals.

## New methods on `Set`

The [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) class now has [more built-in](https://github.com/tc39/proposal-set-methods) methods, thanks to [@kmiller68](https://github.com/kmiller68) at WebKit.

```ts
const a = new Set([1, 2, 3]);
const b = new Set([1, 3, 4, 5]);
const c = new Set([1, 3]);

console.log(a.union(b)); // [1, 2, 3, 4, 5]
console.log(a.intersection(b)); // [1, 3]
console.log(a.difference(b)); // [2]
console.log(a.symmetricDifference(b)); // [2, 4, 5]
```

## AWS Lambda support

Bun can now run AWS Lambda using a [custom layer.](https://github.com/oven-sh/bun/tree/main/packages/bun-lambda#bun-lambda)

The layer will detect when an event is an HTTP request and transform it into a standard [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request). This means you can test your Lambda locally using `bun run`, without any code changes.

```ts
export default {
  async fetch(request: Request): Promise<Response> {
    console.log(request.headers.get("x-amzn-function-arn"));
    // ...
    return new Response("Hello from Lambda!", {
      status: 200,
      headers: {
        "Content-Type": "text/plain",
      },
    });
  },
};
```

For events that are not HTTP requests, like a S3 or SQS trigger, the event will be in the body of the `Request`.

```ts
export default {
  async fetch(request: Request): Promise<Response> {
    const event = await request.json();
    // ...
    return new Response();
  },
};
```

## GitHub Action support

There is a new release of the [`setup-bun`](https://github.com/oven-sh/setup-bun) GitHub Action, which you can also [find](https://github.com/marketplace/actions/setup-bun) on the GitHub Marketplace. Thanks to [@xHyroM](https://github.com/xHyroM) for maintaining the initial version of it.

```yaml
- uses: oven-sh/setup-bun@v1
  with:
    bun-version: latest
```

```yaml
- uses: oven-sh/setup-bun@v1
  with:
    bun-version: "0.5.7"
```

Now, with the newly added support for `git` dependencies, we encourage you to try this out in your GitHub CI and see much time you can save with `bun install`.

```diff
steps:
  - uses: actions/checkout@v3
  - uses: actions/setup-node@v3
    with:
      node-version: 16
+ - uses: oven-sh/setup-bun@v1
+   with:
+     bun-version: latest
+  - run: bun install
-  - run: npm install
```

## Changelog

{% table %}

---

- [`523b112`](https://github.com/oven-sh/bun/commit/523b112945d20f7aa59ad3de327348cc77353a1f)
- Added auto-import for `jest` globals in `bun test` by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`#2029`](https://github.com/oven-sh/bun/pull/2029)
- Fixed `fs.createWriteStream()` from exiting early by [@alexlamsl](https://github.com/alexlamsl)

---

- [`995880a`](https://github.com/oven-sh/bun/commit/995880a7effe692b5482f04d908f07f1227c8f68)
- Enabled more `Set` methods by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`#2039`](https://github.com/oven-sh/bun/pull/2039)
- Fixed "Duplicate dependency" error for `peerDependencies` by [@alexlamsl](https://github.com/alexlamsl)

---

- [`#2044`](https://github.com/oven-sh/bun/pull/2044)
- Fixed incorrect build instructions for macOS by [@ekzhang](https://github.com/ekzhang)

---

- [`#2041`](https://github.com/oven-sh/bun/pull/2041)
- Fixed syntax error when regex was present in `package.json` by [@jwhear](https://github.com/jwhear)

---

- [`675529b`](https://github.com/oven-sh/bun/commit/675529bd0cc7f7753b1d33cf0f14d945bd850654)
- Fixed a bug where Buffer was not assignable by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`#2054`](https://github.com/oven-sh/bun/pull/2054)
- Implemented `napi_fatal_exception` by [@ThatOneBro](https://github.com/ThatOneBro)

---

- [`#2045`](https://github.com/oven-sh/bun/pull/2045)
- Fixed `bun install` crash during non-install script execution by [@alexlamsl](https://github.com/alexlamsl)

---

- [`83473c6`](https://github.com/oven-sh/bun/commit/83473c60df3b7ff4c2326573aa8532b636de4b4e)
- Defined a fallback for `globalPaths` in `require("module")` by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`#2057`](https://github.com/oven-sh/bun/pull/2057)
- Fixed a bug where `server.listen()` did not return the server by [@michalwarda](https://github.com/michalwarda)

---

- [`bb2aaa3`](https://github.com/oven-sh/bun/commit/bb2aaa36fb9e673b23f60345fbba39b5ccc3d3f0)
- Enabled release signing by [@Electroid](https://github.com/Electroid)

---

- [`#2059`](https://github.com/oven-sh/bun/pull/2059)
- Implemented `git://github.com` dependencies by [@alexlamsl](https://github.com/alexlamsl)

---

- [`#2051`](https://github.com/oven-sh/bun/pull/2051)
- Implemented `FormData` by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`0db8cdf`](https://github.com/oven-sh/bun/commit/0db8cdf4e9e79214410454f9225b14f2765bc3c5)
- Fixed `fetch()` not sending a default `Content-Type` header by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`#2061`](https://github.com/oven-sh/bun/pull/2061)
- Implemented `napi_get_value_bigint_words` by [@ThatOneBro](https://github.com/ThatOneBro)

---

- [`#2062`](https://github.com/oven-sh/bun/pull/2062)
- Allowed `{ port: 0 }` in `Bun.serve()` to use a random port by [@michalwarda](https://github.com/michalwarda)

---

- [`37186f4`](https://github.com/oven-sh/bun/commit/37186f4b0a6b97ffb3ac1ec65ddc2146126b4545)
- Improved `console.log()` output for `FormData` by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`#2047`](https://github.com/oven-sh/bun/pull/2047)
- Disallowed bodies when `fetch()` method is GET, HEAD, or OPTIONS by [@ekzhang](https://github.com/ekzhang)

---

- [`#1798`](https://github.com/oven-sh/bun/pull/1798)
- Exported `fs.ReadStream` and `fs.WriteStream` by [@ThatOneBro](https://github.com/ThatOneBro)

---

- [`#2074`](https://github.com/oven-sh/bun/pull/2074)
- Improved validation of `package.json` by [@alexlamsl](https://github.com/alexlamsl)

---

- [`4dc6bf1`](https://github.com/oven-sh/bun/commit/4dc6bf1b099a2a7425a5ff313cff9a9c828f6cd3)
- Added workarounds for `node:tls` and `node:worker_threads` by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`#2076`](https://github.com/oven-sh/bun/pull/2076)
- Fixed a bug where network-delayed `.bin` scripts were not installed by [@alexlamsl](https://github.com/alexlamsl)

---

- [`f19e3d6`](https://github.com/oven-sh/bun/commit/f19e3d66cb82f3e4cbf740a5a1e5fe50c3fd48f3)
- Added a workaround for `node:async_hooks` by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`#1971`](https://github.com/oven-sh/bun/pull/1971)
- Implemented ED25519 for `WebCrypto` by [@Jarred-Sumner](https://github.com/Jarred-Sumner) with thanks to [@panva](https://github.com/panva)

---

- [`0d7cea6`](https://github.com/oven-sh/bun/commit/0d7cea69c253d22fc6ee2ccd7c437290fe9e043c)
- Added a workaround for `eval("__dirname")` by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`1125728`](https://github.com/oven-sh/bun/commit/1125728097e7ccb1891e790299e31d26ef2f7450)
- Fixed bugs with `napi_create_threadsafe_function` by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`#2087`](https://github.com/oven-sh/bun/pull/2087)
- Improved documentation to build on macOS by [@controversial](https://github.com/controversial)

---

- [`#2089`](https://github.com/oven-sh/bun/pull/2089)
- Fixed `writeFileSync({ flag: undefined })` from not working by [@jwhear](https://github.com/jwhear)

---

- [`#2088`](https://github.com/oven-sh/bun/pull/2088)
- Implemented `os.machine()` for Linux by [@jwhear](https://github.com/jwhear)

---

- [`#2086`](https://github.com/oven-sh/bun/pull/2086)
- Supported `yarn`-like workspaces by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`56b75db`](https://github.com/oven-sh/bun/commit/56b75dbac32233b49b33c12ce25a07c9e9083dee)
- Implemented faster `Buffer.byteLength("latin1")` by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`#2095`](https://github.com/oven-sh/bun/pull/2095)
- Fixed `bun add` of packages with capital letters by [@alexlamsl](https://github.com/alexlamsl)

---

- [`#2096`](https://github.com/oven-sh/bun/pull/2096)
- Fixed `String.replace()` with non-ASCII characters by [@jwhear](https://github.com/jwhear)

---

- [`#2094`](https://github.com/oven-sh/bun/pull/2094)
- Supported `git` dependencies by [@alexlamsl](https://github.com/alexlamsl)

---

- [`#2066`](https://github.com/oven-sh/bun/pull/2066)
- Fixed a crash with invalid encoding in `fetch()` headers by [@jwhear](https://github.com/jwhear)

---

- [`1106c8e`](https://github.com/oven-sh/bun/commit/1106c8e2f26ec5f521e33b132594b0741e9caaa3)
- Fixed parsing of `fs` flags by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`#1378`](https://github.com/oven-sh/bun/pull/1378)
- Implemented `os.machine()` for macOS by [@sno2](https://github.com/sno2)

---

- [`#2104`](https://github.com/oven-sh/bun/pull/2104)
- Fixed a change in how URLs are printed by [@MichaReiser](https://github.com/MichaReiser)

---

- [`c006a7f`](https://github.com/oven-sh/bun/commit/c006a7f054fdf19bad5b0783af3305e36f9e3740)
- Load `.env.production` when NODE_ENV=production by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`#2122`](https://github.com/oven-sh/bun/pull/2122)
- Added a pretty string differ to `bun test` by [@dylan-conway](https://github.com/dylan-conway)

---

- [`#2124`](https://github.com/oven-sh/bun/pull/2124)
- Supported `git` dependencies by [@alexlamsl](https://github.com/alexlamsl)

---

- [`#2009`](https://github.com/oven-sh/bun/pull/2009)
- Implemented a runtime layer for Bun on AWS Lambda by [@Electroid](https://github.com/Electroid)

---

- [`#2128`](https://github.com/oven-sh/bun/pull/2128)
- Fixed output in `child_process.exec()` by [@ThatOneBro](https://github.com/ThatOneBro)

---

- [`#2131`](https://github.com/oven-sh/bun/pull/2131)
- Renamed `bun wiptest` to `bun test` by [@dylan-conway](https://github.com/dylan-conway)

---

- [`#2126`](https://github.com/oven-sh/bun/pull/2126)
- Fixed `glibc` error in alpine Docker image by [@WebReflection](https://github.com/WebReflection)

---

- [`#2135`](https://github.com/oven-sh/bun/pull/2135)
- Improved various types for `bun-types` by [@colinhacks](https://github.com/colinhacks)

---

- [`2a1558e`](https://github.com/oven-sh/bun/commit/2a1558e4d6fc2e7abbb9a6f4abc3cc4bb2d49c59)
- Supported Node.js-style `setTimeout()` by [@Jarred-Sumner](https://github.com/Jarred-Sumner)

---

- [`#2097`](https://github.com/oven-sh/bun/pull/2097)
- Supported `AbortSignal` in `fetch()` by [@cirospaciari](https://github.com/cirospaciari)

---

{% /table %}
