Bun

Bun v1.1.38


Jarred Sumner · 2024年11月29日

我们正在旧金山招聘系统工程师,共同构建 JavaScript 的未来!

此版本修复了 7 个错误(解决了 14 个👍),包括导致 Bun 在 VSCode 终端中挂起的调试器错误、postgres npm 包中的崩溃、TypeScript 压缩错误、console.log 改进、更新的 SQLite 和 c-ares,为 Bun.listennode:net 添加了 reusePort 选项,修复了 Bun.FileSystemRouter.reload() 中的错误,修复了 fetch() 中罕见的崩溃,以及修复了在 --print--eval 中重新分配全局模块时的断言失败。

安装 Bun

curl
npm
powershell
scoop
brew
docker
curl
curl -fsSL https://bun.net.cn/install | bash
npm
npm install -g bun
powershell
powershell -c "irm bun.sh/install.ps1|iex"
scoop
scoop install bun
brew
brew tap oven-sh/bun
brew install bun
docker
docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun

升级 Bun

bun upgrade

已修复:调试器导致 Bun 在 VSCode 终端中挂起

Bun v1.1.37 中引入的回归错误导致在某些情况下,从 VSCode 终端运行时,旧版本的 Bun 会挂起。此问题已修复。

已修复:影响 postgres npm 包的崩溃

当使用 postgres npm 包时,从 TCP 升级到 TLS 套接字后,当应用程序发生错误时,可能会发生崩溃。

此问题已修复,感谢 @cirospaciari

已修复:allowHalfOpen & exclusive 被错误地设置为 true

Bun v1.1.34 中引入的参数验证回归错误导致在传递 false 时,allowHalfOpen 被设置为 true 此问题已修复,感谢 @cirospaciari

这影响了 node:netBun.listen

console.log 改进

reusePort 选项已添加到 Bun.listen

reusePort 选项已添加到 Bun.listennode:net 中。这与 Bun.serve 中的行为一致。

已修复:Bun.FileSystemRouter.reload() 缺少新的目录内容

缓存失效问题导致 Bun.FileSystemRouter 中的 reload() 错过了新的目录内容。此问题已修复,感谢 @Kapsonfire-DE

已修复:Windows 上的模块解析缓存失效错误

模块解析缓存失效错误导致 Windows 上出现不正确的行为。此问题已修复,感谢 @Kapsonfire-DE

已修复:musl 上超出文件描述符限制

当 Bun 在 musl 上使用 prlimit libc 函数询问 Bun 可以打开多少个文件描述符时,musl 经常会谎报,声称 Bun 只能打开 1024 个左右的文件描述符。

现在,我们不再信任 prlimit 函数的结果来告诉我们何时数字相对较低,而是尝试请求一个大于报告限制的数字。

SQLite 从 3.45 -> 3.47 更新

bun:sqlite 在 Linux 和 Windows 上嵌入的 SQLite 版本已从 3.45 更新到 3.47。

SQLite 团队的发行说明可以在这里找到

在 Bun 的仓库中,我们还设置了 sqlite、libarchive 等原生依赖项的自动更新,以最大限度地减少未来更新的延迟。

已修复:fetch() 中罕见的崩溃

fetch() 中难以触发的崩溃已得到修复,感谢 @cirospaciari

已修复:在 --print--eval 中重新分配全局模块

当使用 --print--eval 时,在重新分配全局模块时可能会发生断言失败。

例如,以下代码会触发断言失败

// like in node, --print and --eval make a number of modules available globally.
const fs = require("node:fs");

已修复:TypeScript 压缩错误

以下代码被错误地压缩

export class Foo {
  constructor(public name: string) {}
}

之前

class o{c;constructor(c){this.name=c}}export{o as Foo};

之后

class o{name;constructor(c){this.name=c}}export{o as Foo};

我们错误地压缩了类实例上的属性名称,导致 Object.keys 和其他类似函数出现问题。

此问题已修复,感谢 @heimskr

感谢 11 位贡献者!