Bun v1.0.2 fixes numerous bugs and makes bun --watch
faster.
Thank you for reporting issues. We are working hard to fix them as quickly as possible.
Bun is an incredibly fast JavaScript runtime, bundler, transpiler, and package manager — all in one. We've been releasing a lot of changes to Bun recently. Here's a recap of the last few releases. In case you missed it:
v1.0.0
- Bun's first stable release!v1.0.1
- Named imports for .json & .toml files, bugfixes to bun install, node:path, Buffer
To install Bun:
curl -fsSL https://bun.sh/install | bash
npm install -g bun
brew tap oven-sh/bun
brew install bun
docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun
To upgrade Bun:
bun upgrade
bunx <package>@latest
always fetches the latest
Previously, bunx package@latest
would only fetch the latest version of the package if it had not been installed previously in the /tmp
folder (which is cleared every 3 days or on restart, dpending on your OS).
Now, bunx package@latest
will always fetch the latest version of the package. If there is an @
tag and that tag is not a number, it will fetch the query the npm registry for the matching version of the package.
Faster bun --watch
bun --watch <./path-to-file.ts>
lets you watch a file and re-run it when it or any of its imports change. This is useful for development.
Previously, bun --watch
would enqueue a task to the event loop on change to reload the process. That means any blocking or long-running tasks would delay the reload.
Now, it reloads immediately.
In this gif, the current timestamp in milliseconds is printed to the console on restart.
bun run --silent
no longer prints error messages
When running:
bun run --silent bash -c 'exit 1'
Before:
error: "bash" exited with code 1
After:
# nothing!
Bun now uses V8's Date
parser
Bun now uses V8's Date parser. This means that date parsing behaves the same in Bun as it does in Chrome and Node.js.
Previously:
Date.parse("2020-09-21 15:19:06 +00:00"); // Invalid Date
After:
Date.parse("2020-09-21 15:19:06 +00:00"); // 1600701546000
This fixes a number of bugs where date parsing would fail in Bun but work in Node.js.
URL.canParse
is implemented
The URL
class now has a static canParse
method, which returns true
if the URL can be parsed, and false
otherwise.
URL.canParse("https://example.com"); // true
URL.canParse("https://example.com:8080"); // true
URL.canParse("apoksd!"); // false
URL.canParse
is a relatively new addition to the Web Platform. At the time of writing, it is not available in Chrome or Firefox yet.
URLSearchParams.prototype.size
is implemented
The URLSearchParams
class now has a size
property, which returns the number of key/value pairs in the search params.
const params = new URLSearchParams("a=1&b=2&c=3");
params.size; // 3
URLSearchParams.prototype.size
is a relatively new addition to the Web Platform.
Bugfix to bun run
Previously, bun run
would always load tsconfig.json files. This meant that having an invalid tsconfig.json file could cause bun run
to fail, which was completely unnecessary. THis has been fixed.
Bugfix to node:stream
When encoding
was passed to the write
function, the callback
would not be called. This has been fixed.
#75b5c715405d49b5026c13143efecd580d27be1b
Bugfix to fetch with a data:
URL
Previously, invalid data:
URLs would throw an exception in fetch
. This was inconsistent with Node.js which would leave the incorrect data in the URL. This has been fixed, thanks to @davidmhewitt.
#c3455c0ceee6bbe399781819a42fff6cf24792e2
Bugfix to node:readline
(arrow keys)
A bug in node:readline
causing the terminal to hang on WSL has been fixed.
Bugfix to node:dns
A crash in node:dns
's resolve
function has been fixed, thanks to @Hanaasagi.
os.availableParallelism
is implemented
The node:os
module now has an availableParallelism
property, which returns the number of logical CPUs available to the process.
os.availableParallelism(); // 8
You can also use navigator.hardwareConcurrency
.
Bugfixes to Bun.serve()
A crash that could occur when a ReadableStream has enqueued all data before the stream has begun being read has been fixed. This crash happened because the code was missing a check for whether or not a JavaScript function was a callable object.
A crash that could occur when calling req.formData()
has been fixed
Fix set-cookie
A bug causing the set-cookie
header to be set incorrectly in node:http
in some cases has been fixed. This causes issues with Express.js.
node:fs
functions are now concurrent
Previously, only a handful of node:fs
functions were concurrent. Now, all of them are.
Deletable setTimeout
& other globals
Most globals are now configurable/deletable, which fixes issues impacting some libraries and ExecJS.
Bugfix for fastify
Fastify loops over require.cache
during initialization. require.cache
previously included ES Modules which have not finished evaluating yet and that partially broke Fastify. This has been fixed.
Bugfix for multiline string in CRLF terminated files
Thanks to @tikotzky for the fix.
Bugfix for Bun.file()
When the length of the file was less than the size of the Bun.file()
, the file would sometimes not finish reading. This has been fixed, thanks to @cirospaciari.
Bugfix for node:tty
A bug causing WritableStream.prototype.getColorDepth
to sometimes throw an exception has been fixed.
Transpiler bugfix for escaping non-ascii RegExp
literals to latin1
Internal changes
We upgraded from LLVM 15->16 & Clang 15->16.
Full changelog
#5161 | fix(bun-lambda) Fix API Gateway V1 events and expand on Lambda documentation by @mkossoris |
#5159 | fix lifecycle docu by @ximex |
#5151 | docs: fix typos by @s-rigaud |
#5127 | Updated Lambda readme by @tsndr |
#5072 | Add missing full stop on nodejs-apis.md by @diogo405 |
#5069 | update dev build instruction for arch by @mi4uu |
#5046 | fix typo and grammar errors in bunfig.toml by @xNaCly |
#4997 | Update simple.md by @tomredman |
#4990 | Update hot.md by @nazeelashraf |
#5146 | docs: fix typo in import.meta.resolve by @jonathantneal |
#5143 | [Docs] Use git's --global flag for lockfile diffs instead of manually editing config files. by @Southpaw1496 |
#5201 | Various docs by @colinhacks |
#5120 | docs: Made bun-types install as dev dependency in example by @MasterGordon |
#4841 | js/node/stream.js: call write() callback when encoding is not provided by @cfal |
#5234 | Correct the configuration file names. by @nathanhammond |
#5167 | decode regex if needed by @dylan-conway |
#5227 | Update misleading documentation link by @0x346e3730 |
#5061 | file.exists() needs to be awaited to get the value by @amt8u |
#5243 | docs(runtime): fix jsx FragmentFactory output example by @zongzi531 |
#5248 | Add informative message on bun create react by @colinhacks |
#5140 | chore: make comment grammatically correct by @G-Rath |
#5250 | docs(runtime): fix plugins loader extensions typo by @zongzi531 |
#5057 | avoid inserting extraneous"accept-encoding" header by @iidebyo |
#5126 | fix(node/fetch): Make data URL fetch consistent with node by @davidmhewitt |
#5275 | docs: update lockfile diff instructions by @gtramontina |
#5311 | add uninstall instructions by @browner12 |
#5294 | docs(guide): fix expect assertion example in guide for spyOn by @winghouchan |
#5281 | chore(docs): include missing links to Node.js APIs by @styfle |
#5262 | Fixed api & cli docs typo. by @jamesgordo |
#5233 | fix(runtime): require cache should not include unevaluated ESM modules. by @paperdave |
#5236 | Make --watch instant by @Jarred-Sumner |
#5109 | feat(nodejs): implement os.availableParallelism by @WingLim |
#5164 | fix(console.log) fix printing long custom format by @cirospaciari |
#5200 | fix(node:dns): fix crash and compatibility issues with resolve by @Hanaasagi |
#5325 | fix(doc): Add "compilerOptions" to bun-types README.md by @philolo1 |
#5186 | fix(BunFile.slice) fix slice when length is greater than the size by @cirospaciari |
#5229 | More docs & helptext cleanup by @colinhacks |
#5285 | doc(guides): update sveltekit guide by @mroyme |
#5225 | modules documentation didn't have correct import example by @miccou |
#5115 | fix link to "local template" by @desm |
#5244 | chore: test for overwriting _resolveFilename by @paperdave |
#5318 | Fix bug with multiline string in CRLF terminated files (#4893) by @tikotzky |
#5216 | fix(runtime): make most globals configurable/deletable, allow resuming the console iterator by @paperdave |
#5152 | fix(Bun.serve) fix buffering edge case by @cirospaciari |
#4905 | Update nextjs.md by @kryparnold |
#4881 | Update simple.md by @TwanLuttik |
#4452 | Update nuxt.md by @s0h311 |
#5335 | Remove the ability to configure lockfile location. by @nathanhammond |
#5346 | In bunx , always get latest version when @latest is explicitly passed by @Jarred-Sumner |
#5376 | Fix typo in HTTPThread name by @chrisbodhi |
#5379 | docs - Add "workspace:*" to workspace docs. by @dylang |
#4647 | fix(docs): Fix the text that bun run --bun is the same as bun by @DuGlaser |
#5419 | fix warnings during bun run publish-layer by @nangchan |
#5336 | fix(runtime): emit node:net connect error event vs throw by @paperdave |
#5332 | v8 date parser tests by @dylan-conway |
#5360 | async-ify all node:fs functions by @Jarred-Sumner |
#5439 | fix dockerfile by @Jarred-Sumner |
#5428 | fix http set cookie headers by @dylan-conway |
#5422 | fix(nitro) fix sourcemaps and JSSink closing by @cirospaciari |
#5425 | Update docs/quickstart.md by @sonyarianto |
#5341 | dup and close file descriptors by @dylan-conway |
#5459 | Make bun run --silent omit "error: "..." exited with code 1 by @Jarred-Sumner |
#5452 | Does not fix #4622 by @Jarred-Sumner |
#5464 | fix(proxy): allow empty string http_proxy env by @Hanaasagi |
#5463 | Implement URL.canParse by @Jarred-Sumner |
#5467 | Fixes #5461 by @Jarred-Sumner |
#5468 | Fixes #5465 by @Jarred-Sumner |
New contributors
Thanks to Bun's newest contributors!
@mkossoris
@ximex
@s-rigaud
@tsndr
@mi4uu
@xNaCly
@tomredman
@nazeelashraf
@jonathantneal
@Southpaw1496
@MasterGordon
@cfal
@nathanhammond
@0x346e3730
@amt8u
@zongzi531
@G-Rath
@iidebyo
@gtramontina
@browner12
@winghouchan
@philolo1
@mroyme
@miccou
@desm
@tikotzky
@kryparnold
@TwanLuttik
@s0h311
@chrisbodhi
@dylang
@DuGlaser
@nangchan
@sonyarianto