pwshub.com

Bun v1.1.28

Bun v1.1.28 is here! This release fixes 40 bugs (addressing 51 👍). Compile & run C from JavaScript. 30x faster path.resolve. Named pipes on Windows. Several Node.js compatibility improvements and bugfixes.

We're hiring systems engineers in San Francisco to build the future of JavaScript!

To install Bun

curl

curl -fsSL https://bun.sh/install | bash

powershell

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

docker

docker run --rm --init --ulimit memlock=-1:-1 oven/bun

To upgrade Bun

Compile & run C from JavaScript

Bun now supports compiling and running C from JavaScript. This is a simple way to use native system libraries from JavaScript without adding an extra build step.

Learn more about this feature here.

30x faster path.resolve

This release makes path.resolve 30x faster.

Named pipes on Windows

Bun now supports named pipes on Windows in many Node.js & Bun APIs, thanks to @cirospaciari! Named pipes are interesting because they're not exactly files on disk. They're this other thing, sort of like Unix domain sockets but also not.

Node.js compatibility improvements

process._exiting is set to false

Previously, process._exiting would be set to undefined before the exit event was emitted. Now, it will be false

console.log(process._exiting); // Previously: `undefined`, now: `false`

process.on("exit", () => {
  console.log(process._exiting); // true
});

workerData from worker_threads defaults to null

The default value of workerData has been changed from undefined to null.

import { workerData } from "worker_threads";

console.log(workerData); // Previously: `undefined`, now: `null`

Missing constants from perf_hooks have been added

The following constants were previously missing from the perf_hooks module:

import { constants } from "perf_hooks";
console.log(constants.NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE); // 7
console.log(constants.NODE_PERFORMANCE_MILESTONE_ENVIRONMENT); // 2
console.log(constants.NODE_PERFORMANCE_MILESTONE_LOOP_EXIT); // 6
console.log(constants.NODE_PERFORMANCE_MILESTONE_LOOP_START); // 5
console.log(constants.NODE_PERFORMANCE_MILESTONE_NODE_START); // 3
console.log(constants.NODE_PERFORMANCE_MILESTONE_TIME_ORIGIN_TIMESTAMP); // 0
console.log(constants.NODE_PERFORMANCE_MILESTONE_TIME_ORIGIN); // 1
console.log(constants.NODE_PERFORMANCE_MILESTONE_V8_START); // 4
console.log(constants.NODE_PERFORMANCE_ENTRY_TYPE_DNS); // 4
console.log(constants.NODE_PERFORMANCE_ENTRY_TYPE_GC); // 0
console.log(constants.NODE_PERFORMANCE_ENTRY_TYPE_HTTP); // 1
console.log(constants.NODE_PERFORMANCE_ENTRY_TYPE_HTTP2); // 2
console.log(constants.NODE_PERFORMANCE_ENTRY_TYPE_NET); // 3

Fixed logic for undefined options provided node:zlib

Option handling in node:zlib has been fixed, allowing options to be undefined without causing an error.

import { createGzip } from "zlib";

createGzip({ level: undefined });

After headers have been sent, req.headersSent will be set to true

Added timers.promises

Exports from node:timers/promises are now also available in timers.promises to better match Node.js.

import { promises } from "timers";

console.time("timeout");
await promises.setTimeout(1000);
console.timeEnd("timeout"); // [1002.48ms] test

Fixed: cwd is updated before searching for executables in node:child_process before spawning processes

Previously, Bun would search for executables to spawn in the calling process's cwd. If a different cwd was provided and a relative path was given for the executable path, the expected executable would fail to be found. Now, Bun will search from the target cwd.

import { spawnSync } from "child_process";
import { join } from "path";

// This will search for `foo` in `./node_modules/package/bin/`
spawnSync("./bin/foo", { cwd: join(import.meta.dir, "node_modules/package") });

Fixed: crash in napi escapable handle scopes

A bug where napi escapable handle scopes could crash Bun has been fixed, thanks to @190n!

Fixed: crash in napi handle scope finalization

A bug where a napi finalizer is called and then we attempt to allocate a handle scope has been fixed. This would cause a crash in certain cases in the sqlite3 package. This was a regression from v1.1.27. Thanks to @190n for the fix!

More fixes and improvements

Fixed an edgecase with os and cpu fields in bun install

In certain cases, the os and cpu fields in bun install would not handle exclusions properly, leading to always-skipped installs. This has been fixed.

We've also added an extra log message in bun install --verbose to make it easier to debug why a package is being skipped.

Fixed: IPC through bun run

Previously, if you spawned a process that opened bun run with IPC enabled, the IPC socket would be closed before the child process could use it. This has been fixed, thanks to @snoglobe!

Fixed: case-insensitive watch mode on Windows

On Windows, watch mode would not pick up on changes to case-sensitive files in certain cases. This has been fixed, thanks to @dylan-conway!

Fixed: bun ./bun.lockb would print env loaded message

If you ran bun ./bun.lockb, with a .env file in the same directory Bun would print a mesasge telling you it loaded the .env file. It shouldn't be loading the .env file, but regardless it also shouldn't be printing a message when it did load the .env file since that's noise when you're just trying to see a yarn.lock printed from the bun.lockb. This has been fixed, thanks to @snoglobe!

Fixed: Bun.file(path).text() on Windows not reading to end of file sometimes

On Windows, in certain cases, Bun.file(path).text() would not read to the end of the file. This has been fixed, thanks to @190n!

Fixed: React 19 production mode SSR

React 19 changed the symbol used for identifying JSX elements. This broke Bun's JSX inlining optimization. To continue to support React 19, we've disabled the optimization for now.

Thanks to @paperdave for the fix!

Fixed: DOMJIT crash with TextDecoder

A crash that could occur when throwing an exception from a TextDecoder has been fixed. DOMJIT is a neat feature in JavaScriptCore that allows us to leverage type information at build-time to call natively-implemented JS functions around 30% faster. We added typed array support to this some time ago, but it has proven to cause crashes in certain cases - so we're disabling it for now and will re-enable it once we make this API more robust.

Thanks to 12 contributors!

Source: bun.sh

Related stories
1 month ago - Support for `TextEncoderStream` and `TextDecoderStream`, 50% faster `console.log(string)`, support for `Float16Array`, Node.js<>Bun IPC on Windows, truncate large arrays in `console.log()`, and many more bug fixes and Node.js...
23 hours ago - Bun now supports compiling and running C from JavaScript to make using systems libraries easier.
1 week ago - Fixes 130 bugs (addressing 250 👍). `bun pm pack`, faster `node:zlib`. Static routes in Bun.serve(). ReadableStream support in response.clone() & request.clone(). Per-request timeouts. Cancel method in ReadableStream is called. `bun run`...
1 month ago - Fixes 72 bugs (addressing 63 👍). 30% faster fetch() decompression, New --fetch-preconnect flag, improved Remix support, Bun gets 4 MB smaller on Linux, bundle packages excluding dependencies, many bundler fixes and node compatibility...
1 month ago - Fixes 79 bugs (addressing 93 👍). Express is now 3x faster in Bun, ES modules load faster on Windows, 10% faster Bun.serve() at POST requests, source maps in `bun build --compile`. Memory usage reductions to `--hot`, Bun.serve(), and...
Other stories
52 minutes ago - This release candidate, a near-final look at Deno 2, includes the addition of Node's process global, better dependency management, and various API stabilizations, and more.
1 hour ago - Published: September 19, 2024 The CSS Working Group has combined the two CSS masonry proposals into one draft specification. The group hopes that...
1 hour ago - Stay organized with collections Save and categorize content based on your preferences. Published: September...
2 hours ago - DNS monitoring tool is a cloud-based scanner that constantly monitors DNS records and servers for anomalies. This tool aims to ensure that users are sent to genuine and intended website pages, instead of fakes or replicas. It alerts users...
3 hours ago - Email spoofing is a malicious tactic in which cybercriminals send fake emails that look like they come from trusted organizations or individuals. When unsuspecting users act on these emails, they may unknowingly share sensitive data,...