Bun v1.2.22 Adds Unified SQL Client, Async Stack Traces & 500× Speed Boost

Bun's latest releases (v1.2.21 and v1.2.22) introduce a unified SQL client for MySQL/MariaDB, SQLite and PostgreSQL, native YAML parsing, massive performance improvements such as a 500‑fold postMessage boost, async stack trace support, enhanced security tools, executable compilation features, and extensive Node.js compatibility fixes.

IT Services Circle
IT Services Circle
IT Services Circle
Bun v1.2.22 Adds Unified SQL Client, Async Stack Traces & 500× Speed Boost

JavaScript runtime Bun recently released two important versions: v1.2.21 on August 25, 2025, fixing 69 issues and adding major features, followed by v1.2.22 on September 14, 2025, which introduced the long‑awaited async stack trace capability.

图片
图片

Unified SQL client: one API for three major databases

Bun v1.2.21’s headline feature is Bun.SQL, a zero‑dependency client that can connect to MySQL/MariaDB, SQLite and PostgreSQL.

MySQL and MariaDB support

The MySQL/MariaDB driver is written in Zig and offers excellent performance. Connections can be created via an options object or a URL string:

import { SQL } from "bun");
const sql = new SQL({
  adapter: "mysql",
  hostname: "127.0.0.1",
  username: "user",
  password: "password",
  database: "buns_burgers"
});
const users = await sql`SELECT * FROM users;`.all();

In v1.2.22 the MySQL adapter gains affectedRows and lastInsertRowid properties, fixes column‑type handling, and adds TLS support with mysql_native_password authentication.

SQLite integration

Bun.SQL

also includes built‑in SQLite support, extending the concise template‑literal API to SQLite users:

const db = new SQL(":memory:");
await db`CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);`;
const users = await db`SELECT * FROM users ORDER BY name ASC`;

Native YAML support

Bun v1.2.21 ships with a YAML parser. Developers can import .yaml or .yml files directly, or parse strings at runtime with Bun.YAML.parse, matching the built‑in JSON and TOML support.

// Import a YAML file
import pkg from "./package.yaml";
console.log(pkg.name); // "my-package"

// Parse a YAML string
import { YAML } from "bun";
const items = YAML.parse("- item1
- item2");

Performance boost

postMessage performance 500×

Bun v1.2.21 dramatically speeds up postMessage between workers and the structuredClone of strings, achieving up to a 500‑fold improvement. v1.2.22 further optimizes simple object handling, adding a fast path for pure JavaScript objects and delivering a 240× speed increase.

Reduced idle CPU usage

Previously, Bun.serve woke once per second to update the Date header even when idle, consuming CPU. The timer now activates only on incoming requests, allowing the process to truly sleep when idle.

Async stack trace

v1.2.22 finally provides async stack traces, showing the full asynchronous call chain in error stacks, greatly improving debugging of async/await code.

async function foo() {
  return await bar();
}
async function baz() {
  await 1;
  throw new Error("oops");
}
// Stack now includes:
// at baz (async.js:11:13)
// at async bar (async.js:6:16)
// at async foo (async.js:2:16)

Security and developer tool enhancements

Bun.secrets local key management

Bun.secrets

uses the operating system’s native credential store (Keychain on macOS, libsecret on Linux, Credential Manager on Windows) to securely store and retrieve secrets.

Package manager security scan API

bun install

now scans packages for vulnerabilities before installation. The bunfig.toml file can configure the scanner, aborting the install on fatal issues.

bun audit new filter options

The bun audit command adds flags such as --audit-level, --prod, and --ignore to set severity thresholds, audit only production dependencies, or ignore specific CVEs, facilitating CI/CD integration.

Compilation and bundling improvements

Bun.build() supports compiling executables

The former CLI‑only --compile flag is now available via the JavaScript API. Developers can programmatically create standalone executables and target platforms:

await Bun.build({
  entrypoints: ["./cli.ts"],
  compile: {
    target: "bun-windows-x64",
    outfile: "./my-app-windows",
    windows: { icon: "./icon.ico" }
  }
});

Windows executable metadata

Standalone Windows executables can now embed metadata such as title, publisher, version, description, and copyright, visible in file properties.

Node.js compatibility improvements

Both releases fix numerous Node.js compatibility issues, including TypeError on WebSocket upgrade interruption, N‑API plugin assertion failures, child_process stdio handling, crypto algorithm name case sensitivity, and various fixes in readline, net, http2, and other core modules.

WebSocket upgrade TypeError

N‑API plugin assertion failures

child_process stdio stream handling

crypto module algorithm name case issues

readline, net, http2 compatibility fixes

For full details see: https://bun.com/blog/bun-v1.2.22

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

SQLBunAsyncbuild
IT Services Circle
Written by

IT Services Circle

Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.