Bun v0.2.2 #1401
Jarred-Sumner
announced in
Announcements
Bun v0.2.2
#1401
Replies: 3 comments 1 reply
-
So the WebKit webcrypto bugs and oddities are now in Bun? ;) no really, psyched, i'll unleash my interop test suite on it in the evening and report back. |
Beta Was this translation helpful? Give feedback.
1 reply
This comment was marked as off-topic.
This comment was marked as off-topic.
-
Android root throws error
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
To upgrade:
To install:
curl https://bun.sh/install | bash
TLDR:
fs.createReadStream
works nowBun.peek
TCP sockets
Bun now has support for TCP clients and servers. You can use it to implement database clients, game servers, or anything else that needs to use TCP instead of HTTP.
A TCP echo server runs 30% faster in Bun compared to Node:
It is designed to be fast. Instead of promises or assigning callbacks for each socket, like the Node.js EventEmitter or the standard WebSocket API, callbacks are defined once for optimal performance and better code readability.
Start a TCP server
Start a TCP client
There is also support for:
You can read more about TCP sockets in the README.
This API is very new and I imagine there are still some bugs to fix. Please file issues about any bugs you run into!
Bug fixes
Bun has a special transform for importing builtin modules which converts them from asynchronous ESM imports into synchronous ESM
import.meta.require
. A transpiler bug whendefault
was imported in these builtin Bun modules along with other named imports caused a runtime error:The bug was due to how Bun's transpiler rewrote those imports. In this case,
default
is equivalent to the namespace object (only for these builtin modules which may not actually point to JavaScript source code)Now, Bun transpiles the above into:
When an import fails to resolve at build time, Bun throws a
ResolveError
.ResolveError
includes aposition
object that exposes detailed line & column information about where the file was originally imported.There was a bug where Bun would crash if you attempted to access the
position
object when it came from anawait import
which imported another file that failed to resolveFile A:
file-b.js
:This bug has been fixed.
Error handling logic for
new Response(Bun.file(fileDescriptorAsANumber))
when used with the HTTP server expected it to be used with file paths instead of file descriptor numbers, causing a crash. Thanks to @sno2 for the fix.An edgecase involving hex-escaped RegExp literals with lookbehinds caused our Oniguruma polyfill from v0.2.1 to throw an error. This was fixed thanks to @dylan-conway
More bug fixes:
ReadableStream.prototype.tee
function did not work when used with"direct"
streams 360a007error
handler inBun.serve
@zhiyuang in Fix lexer expected token error #1387Bun.peek
Sometimes you have code that is
async
, but you know it is not actuallyasync
. The newpeek
function will allow you to read a promise's result without await or .then, but only if the promise has already fulfilled or rejected.It is useful for performance-sensitive code where you want to reduce the number of extra microticks. It's an advanced API and you (probably) shouldn't use it unless you know what you're doing.
You can read more about
peek
in the README.Node.js streams
In addition to new APIs, we continue to make progress towards Node.js compatibility. Bun now supports
fs.createReadStream
and has generally improved support for Node.js streams.WebCrypto API
The standard WebCrypto API is now implemented, thanks to the many contributors at WebKit.
WebCrypto is a low-level API, so we only recommend using it when you know a little more than a thing or two about cryptography. However, there are popular libraries that depend on WebCrypto that you can now use with Bun.
Here's an example using a package that depends on WebCrypto:
jose
by @panva.Homebrew
You can now install or upgrade Bun with our official Homebrew tap.
You can also install a specific version.
You can also upgrade with either
brew
orbun
.brew upgrade bun bun upgrade # still works
All the PRs
$BUN_INSTALL
and$XDG_CACHE_HOME
to$HOME
. by @lgarron in Cache dir loader: Prefer$BUN_INSTALL
and$XDG_CACHE_HOME
to$HOME
. #1351var
usages by @sno2 in chore: remove outdatedvar
usages #1364new Response(null)
from segfaulting by @sno2 in fix(fetch): stopnew Response(null)
from segfaulting #1383New Contributors
$BUN_INSTALL
and$XDG_CACHE_HOME
to$HOME
. #1351Full Changelog: bun-v0.2.1...bun-v0.2.2
This discussion was created from the release Bun v0.2.2.
Beta Was this translation helpful? Give feedback.
All reactions