1
0
Fork 0
mirror of https://github.com/oven-sh/bun.git synced 2026-05-13 22:20:52 -04:00
Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one https://bun.com
  • Zig 60.4%
  • C++ 24.6%
  • TypeScript 9.1%
  • C 3.3%
  • JavaScript 1.4%
  • Other 0.8%
Find a file
Ciro Spaciari b8ecc78b03
http: gate fetch TCP keepalive on the existing keepalive option (#30640)
Includes #30637 (undici source link for the 60s default).

Mirror undici's `options.keepAlive` guard in
[`buildConnector`](f33a6cb615/lib/core/connect.js (L121-L124)):
when `fetch(url, { keepalive: false })` is used (which already disables
HTTP connection reuse), also skip the `SO_KEEPALIVE` `setsockopt`
instead of applying it unconditionally.

### `node:http` / `node:https` defaults (no changes needed)

`ClientRequest` already forwards `agent.keepAlive` to fetch's
`keepalive` in
[`_http_client.ts`](../blob/b1cc6187ab/src/js/node/_http_client.ts#L298-L302),
and both global agents are constructed with `{ keepAlive: true,
scheduling: "lifo", timeout: 5000 }` — matching Node 19+:

| | `agent.keepAlive` | TCP `SO_KEEPALIVE` |
| --- | --- | --- |
| `http.globalAgent` / `https.globalAgent` | `true` | on (60s, undici
default) |
| `new Agent()` / `agent: false` | `false` | off |

### How did you verify your code works?

`test/js/web/fetch/fetch-tcp-keepalive.test.ts` (Linux-only, reads
`/proc/self/net/tcp`) extended with cases for `keepalive: false`,
`node:http` `agent: false`, and `node:http` `globalAgent`.

---------

Co-authored-by: robobun <117481402+robobun@users.noreply.github.com>
2026-05-13 16:52:15 -07:00
.buildkite ci: don't skip tests when GitHub PR-files API fails; cache via meta-data (#29890) 2026-04-28 16:43:38 -07:00
.claude restructure src/: path fixups + extract JSC bridges and leaf types 2026-05-04 03:20:16 -07:00
.cursor chore: convert .cursor/rules to .claude/skills (#25683) 2025-12-24 23:37:26 -08:00
.github github-actions: pin action versions (#30575) 2026-05-12 13:38:04 -07:00
.vscode restructure src/: path fixups + extract JSC bridges and leaf types 2026-05-04 03:20:16 -07:00
bench Bun.serve: rename h3/h1 options to http3/http1 (#30583) 2026-05-12 15:12:49 -07:00
completions Add bun test --shard=M/N for splitting tests across CI jobs (#29366) 2026-04-17 17:14:07 -07:00
dockerhub test: add regression tests for building docker containers (#25210) 2025-12-01 20:20:06 -08:00
docs docs(server): fix line-wrapped code span in HTTP/3 note (#30591) 2026-05-12 16:18:08 -07:00
misctools Remove dead files (#28847) 2026-04-04 10:02:54 -07:00
packages Bun.serve: rename h3/h1 options to http3/http1 (#30583) 2026-05-12 15:12:49 -07:00
patches Bun.Image — Sharp-shaped image pipeline (jpeg/png/webp, resize, rotate, modulate) (#30032) 2026-05-02 19:15:31 -07:00
scripts Bun.serve: rename h3/h1 options to http3/http1 (#30583) 2026-05-12 15:12:49 -07:00
src http: gate fetch TCP keepalive on the existing keepalive option (#30640) 2026-05-13 16:52:15 -07:00
test http: gate fetch TCP keepalive on the existing keepalive option (#30640) 2026-05-13 16:52:15 -07:00
.aikido Add new package paths to .aikido configuration 2025-11-20 17:35:16 -08:00
.bk.yaml scripts: replace buildkite-failures.ts with bk-backed ci:* helpers (#28877) 2026-04-04 17:41:26 -07:00
.clang-tidy Reapply "Convert build scripts to CMake (#13427)" 2024-09-11 08:24:50 -07:00
.clangd meta: fix disabling of clangd auto header insertion (#17172) 2025-02-10 02:04:21 -08:00
.coderabbit.yaml Disable coderabbit enrichment 2025-12-18 18:03:23 -08:00
.cursorignore Update .cursorignore 2024-12-26 11:48:30 -08:00
.dockerignore bump webkit (#15328) 2024-12-12 03:21:56 -08:00
.editorconfig Bring uSockets & uWebSockets forks into Bun's repository (#4372) 2023-08-28 08:38:30 -07:00
.git-blame-ignore-revs Update .git-blame-ignore-revs 2025-06-13 16:16:14 -07:00
.gitattributes restructure src/: path fixups + extract JSC bridges and leaf types 2026-05-04 03:20:16 -07:00
.gitignore restructure src/: path fixups + extract JSC bridges and leaf types 2026-05-04 03:20:16 -07:00
.lldbinit Move LLDB initialization commands to make attach configuration work (#20085) 2025-05-30 19:33:03 -07:00
.mailmap do not print duplicate code (#16231) 2025-01-07 20:19:12 -08:00
.prettierignore docs: revert minifier doc's format (#24639) 2025-11-12 11:01:25 -08:00
.prettierrc Add new bindings generator; port SSLConfig (#23169) 2025-10-03 17:10:28 -07:00
.typos.toml ci: check for typos in documentation (#16235) 2025-01-08 07:23:54 +00:00
AGENTS.md Make AGENTS.md a symlink to CLAUDE.md 2025-06-27 21:13:21 -07:00
build.zig Add bun.sys.sigaction with bionic-correct layout for Android (#30389) 2026-05-08 00:49:37 -07:00
bun.lock Support TypeScript 6 2026-03-25 16:39:54 +00:00
bunfig.node-test.toml node:module compatibility pt 1 (#18106) 2025-03-12 15:47:41 -07:00
bunfig.toml install: global virtual store for isolated linker (7x faster warm installs) (#29489) 2026-04-21 02:51:15 -07:00
CLAUDE.md restructure src/: path fixups + extract JSC bridges and leaf types 2026-05-04 03:20:16 -07:00
CODE_OF_CONDUCT.md Add a code of conduct 2022-09-03 20:54:15 -07:00
CONTRIBUTING.md scripts: replace buildkite-failures.ts with bk-backed ci:* helpers (#28877) 2026-04-04 17:41:26 -07:00
entitlements.debug.plist Faster debug builds (#16354) 2025-01-12 20:03:24 -08:00
entitlements.plist New subcommand: bun upgrade. It upgrades bun to the latest version. 2021-10-28 05:34:38 -07:00
flake.lock Add Nix flake for development environment (#23406) 2025-10-10 02:13:28 -07:00
flake.nix [publish images] Upgrade LLVM toolchain from 19.1.7 to 21.1.8 (#26667) 2026-02-02 23:12:21 -08:00
LATEST Bump 2026-04-23 14:40:47 -07:00
LICENSE.md Bun.Image — Sharp-shaped image pipeline (jpeg/png/webp, resize, rotate, modulate) (#30032) 2026-05-02 19:15:31 -07:00
meta.json feat(build): add --metafile-md CLI option for LLM-friendly bundle analysis (#26441) 2026-01-28 18:01:39 -08:00
oxlint.json lint: remove no-undef-init from oxlint.json (#28728) 2026-03-31 13:42:52 -07:00
package.json restructure src/: path fixups + extract JSC bridges and leaf types 2026-05-04 03:20:16 -07:00
README.md Update README.md 2026-05-04 19:00:13 -07:00
rust-toolchain.toml [publish images] Add x86_64/aarch64-freebsd & android target (#29676) 2026-04-26 05:00:19 -07:00
SECURITY.md bun.sh -> bun.com (#20909) 2025-07-10 00:10:43 -07:00
shell.nix [publish images] Upgrade LLVM toolchain from 19.1.7 to 21.1.8 (#26667) 2026-02-02 23:12:21 -08:00
tsconfig.base.json Add new bindings generator; port SSLConfig (#23169) 2025-10-03 17:10:28 -07:00
tsconfig.json types: Rewrite to avoid conflicts and allow for doc generation (#18024) 2025-03-25 14:33:30 -07:00
workspace.code-workspace go 2021-08-11 13:56:03 -07:00

Logo

Bun

stars Bun speed

Documentation   •   Discord   •   Issues   •   Roadmap

Read the docs →

What is Bun?

Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called bun.

At its core is the Bun runtime, a fast JavaScript runtime designed as a drop-in replacement for Node.js. It's written in Zig and powered by JavaScriptCore under the hood, dramatically reducing startup times and memory usage.

bun run index.tsx             # TS and JSX supported out-of-the-box

The bun command-line tool also implements a test runner, script runner, and Node.js-compatible package manager. Instead of 1,000 node_modules for development, you only need bun. Bun's built-in tools are significantly faster than existing options and usable in existing Node.js projects with little to no changes.

bun test                      # run tests
bun run start                 # run the `start` script in `package.json`
bun install <pkg>             # install a package
bunx cowsay 'Hello, world!'   # execute a package

Install

Bun supports Linux (x64 & arm64), macOS (x64 & Apple Silicon), and Windows (x64 & arm64).

Linux users — Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1.

x64 users — if you see "illegal instruction" or similar errors, check our CPU requirements

# with install script (recommended)
curl -fsSL https://bun.com/install | bash

# on windows
powershell -c "irm bun.sh/install.ps1 | iex"

# with npm
npm install -g bun

# with Homebrew
brew tap oven-sh/bun
brew install bun

# with Docker
docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun

Upgrade

To upgrade to the latest version of Bun, run:

bun upgrade

Bun automatically releases a canary build on every commit to main. To upgrade to the latest canary build, run:

bun upgrade --canary

View canary build

Guides

Contributing

Refer to the Project > Contributing guide to start contributing to Bun.

License

Refer to the Project > License page for information about Bun's licensing.