Bun v1.0.7 fixes 59 bugs (addressing 78 👍 reactions), implements optional peer dependencies in bun install, and makes improvements to Node.js compatibility.
Bun is an incredibly fast JavaScript runtime, bundler, transpiler, and package manager — all in one. In case you missed it, here are some of the recent changes to Bun:
v1.0.0- First stable release!v1.0.1- Named imports for .json and .toml files, fixes tobun install,node:path, andBufferv1.0.2- Make--watchfaster and lots of bug fixesv1.0.3-emitDecoratorMetadataand Nest.js support, fixes for private registries and morev1.0.4-server.requestIP, virtual modules in runtime plugins, and morev1.0.5- Fixed memory leak withfetch(),KeyObjectsupport innode:cryptomodule,expect().toEqualIgnoringWhitespaceinbun:test, and morev1.0.6- Fixes 3 bugs (addressing 85 👍 reactions), implementsoverrides&resolutionsinpackage.json, and fixes regression impacting Docker usage with Bun
To install Bun:
curl -fsSL https://bun.sh/install | bashnpm install -g bunbrew tap oven-sh/bunbrew install bundocker pull oven/bundocker run --rm --init --ulimit memlock=-1:-1 oven/bunTo upgrade Bun:
bun upgradebun install improvements
This release includes several bugfixes to bun install, such as:
New: Optional peerDependencies
This release adds support for optional peer dependencies, which addresses a bug where bun install would potentially install more packages than npm install.
An optional peer dependency appears in a package.json looks like this:
{
"peerDependencies": {
"node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0"
},
"peerDependenciesMeta": {
"node-notifier": {
"optional": true
}
}
}
This tells the npm client to not install node-notifier, unless it is explicitly listed in the dependencies or devDependencies of the root project's package.json.
In the previous release, Bun would install node-notifier even if it wasn't listed in the root project's package.json. This would increase the size of node_modules and potentially could cause issues where Bun would intall the same package under multiple versions. In Bun v1.0.7, this has been fixed.
Thanks to @dylan-conway for implementing optional peer dependencies in Bun!
Fixed: Edgecase where wrong version of packages were installed
There was a bug where bun install would sometimes choose older versions of packages when matching the semver range. This has been fixed, thanks to @dylang.
Specifically, we assumed the npm registry API returned the list of package versions in semver order. The official registry API usually does, but not always. Moreover, not everyone uses the official registry API. This caused bun install to sometimes choose older versions of packages that still matched the semver range.
Bun will now sort the versions retreived from the registry, before choosing the best version that matches.
Fixed: bun install github:foo/foo could save multiple times to package.json
A bug caused bun install github:foo/foo to save multiple times to package.json. If you ran it twice, the dependency would appear multiple times in package.json. This bug has been fixed, thanks to @dylan-conway.
Fixed: Edgecase causing non-deterministic bun.lockb on Linux
A determinism issue caused bun.lockb to sometimes have differing contents on Linux. This has been fixed, thanks to @dylan-conway.
Fixed: npm alias edgecase bugfix
A bug causing npm: aliases in dependencies to not always be respected has been fixed, thanks to @dylan-conway.
Node.js compatibility improvements
This release also includes several Node.js compatibility improvements.
Fixed: child_process IPC reliability
A reliability issue causing IPC messages to not send all their contents has been fixed, thanks to @paperclover. This helps Next.js work more reliably in Bun, though there is still have more work to be done there.
Fixed: Hanging socket without end event
A bug causing node:net sockets to not correctly emit an end event in all cases has been fixed, thanks to @cirospaciari.
This bug impacted the pg and sequelize packages, among others.
Fixed: napi memory leak
A memory leak in napi has been fixed, thanks to @alangecker. The root cause was a reference count that started at 1 instead of 0.
Fixed: node:stream crash
A crash that could potentially occur when writing many small chunks to a node:stream has been fixed, thanks to @paperclover.
Fixed: server.address() for Unix sockets
A bug causing server.address() in node:http to return incorrect values for unix sockets has been fixed, thanks to @Hanaasagi.
Fixed: threadId was unset in Worker
A bug causing threadId to not be set in the Worker instance returned in node:worker_threads has been fixed, thanks to @jerome-benoit.
Fixed: Buffer.write with 'binary' truncated to ascii instead of latin1
A bug causing Buffer.write with 'binary' encoding to truncate to ascii rather than latin1 has been fixed, thanks to @Electroid.
Fixed: Buffer.concat(buffers, undefined) threw an error
A bug where the following code would throw an error has been fixed, thanks to @Hanaasagi.
Buffer.concat([Buffer(1), Buffer(1)], undefined);
The following code would not throw an error:
Buffer.concat([Buffer(1), Buffer(1)]);
Buffer.concat([Buffer(1), Buffer(1)], 2);
The bug was checking for the native code equivalent of arguments.length instead of whether or not arguments[1] was undefined.
Fixed: node:dns lookup returned wrong address for family
A bug causing node:dns's lookup function to return the wrong address type when family was set has been fixed, thanks to @Electroid. For example, dns.lookup('localhost', { family: 6 }) could have returned an IPv4 address instead of an IPv6 address.
Runtime fixes
We also fixed several bugs in the Bun runtime.
Fixed: Bug causing docker container to throw incorrect "port in use" errors
A bug causing Bun to throw incorrect "port in use" errors when running in a Docker container has been fixed, thanks to @Hanaasagi.
When binding to IPv6 address failed, Bun would immediately return an error. Now, it also attempts to bind to IPv4 addresses and only returns an error if that also fails. This is because of a long-standing issue where Docker would contain IPv6 entries in /etc/hosts, even when IPv6 was disabled.
Fixed: request.url would sometimes have incorrect port
An edgecase causing request.url to sometimes have an incorrect port has been fixed, thanks to @Electroid.
Fixed: Missing statusText in Response
A bug causing response.statusText to be missing has been fixed, thanks to @toshok.
Fixed: WebSocket client Host header missing port
A bug where the port number was not included in the Host header sent by the WebSocket client has been fixed, thanks to @Electroid.
Fixed: Bun.write reported wrong path in error message
A bug causing Bun.write to report the wrong path in error messages has been fixed, thanks to @Hanaasagi.
Fixed: statement.all() in SQLite sometimes returned a number instead of an array
In certain cases bun:sqlite's statement.all() function returned a number instead of an array. This was very confusing and has been fixed to always return an array, thanks to @HForGames.
Fixed: describe.only didn't work for nested describe scopes
A bug in bun:test causing describe.only to not work for nested describe scopes has been fixed, thanks to @igorshapiro.
Preperation for regular Windows builds
We are making changes to our build system in preparation for regular Windows builds.
Bun will soon switch to use cmake and ninja for builds, rather than a 2000+ line Makefile. Bun will also start using the debug builds of JavaScriptCore, which enables various assertions that help us catch bugs earlier. This release implements most of the changes necessary for that, thanks to @paperclover.
Bun will also upgrade from LLVM 16 to LLVM 17 in the next release.
New Contributors
Thanks to our 17 new contributors 🎉
@clay-currymade their first contribution in#6479@jerome-benoitmade their first contribution in#6521@Voldematmade their first contribution in#6128@toshokmade their first contribution in#6151@HForGamesmade their first contribution in#5946@yschroemade their first contribution in#5485@Connormihamade their first contribution in#4975@aralrocamade their first contribution in#6558@pierre-cmmade their first contribution in#6563@klatkamade their first contribution in#6153@mountainashmade their first contribution in#6579@owlcodemade their first contribution in#6587@nygmaaamade their first contribution in#6581@vladamanmade their first contribution in#6208@PaulaBurgheleaGithubmade their first contribution in#6620@alangeckermade their first contribution in#6598@imcatwhocodemade their first contribution in#6590