---
title: "Bun v0.2.1"
description: "Bun.serve() gains built-in server-side WebSocket support powered by uWebSockets, with a server.upgrade(req) call that handles the Sec-WebSocket-Key check automatically."
url: "https://swe.quest/articles/bun-v0-2-1-3bfed6610fb07736"
canonical: "https://bun.com/blog/bun-v0.2.1"
source: "Bun"
published: "2022-10-19"
difficulty: "medium"
kind: "Release"
reading_minutes: 2
tags: ["javascript","runtimes","realtime"]
---

# Bun v0.2.1

A post on [Bun](https://swe.quest/sources/bun.md), published 2022-10-19, 2 min read, Release. Original: [https://bun.com/blog/bun-v0.2.1](https://bun.com/blog/bun-v0.2.1)

## Summary

Bun.serve() gains built-in server-side WebSocket support powered by uWebSockets, with a server.upgrade(req) call that handles the Sec-WebSocket-Key check automatically. RegExp lookbehind assertions, needed by packages like Discord.js, now work through a fallback Oniguruma engine: the transpiler rewrites such regex literals into Bun.OnigurumaRegExp until JavaScriptCore supports them natively. Smaller changes include a Date header on HTTP responses, performance.timeOrigin, DOMJIT bindings for ServerWebSocket send/publish methods, and fixes for an HTTP memory leak, a buffered-response memory aliasing bug and WebSocket client pong handling.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [Runtimes & VMs](https://swe.quest/tags/runtimes.md) (Compilers & runtimes)
- [Real-time systems](https://swe.quest/tags/realtime.md) (Backend & APIs)

## Prerequisites

- JavaScript runtimes ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))
- WebSocket protocol basics

## Keywords

Bun, Bun.serve, uWebSockets, Oniguruma, JavaScriptCore, DOMJIT, WebSocket

## Related posts

- [Bun v0.6.3](https://swe.quest/articles/bun-v0-6-3-6490ca20e0e273a3.md): Bun · 2023-05-22 · Medium · 6 min read · JavaScript, Runtimes & VMs, Testing, Build systems
  Bun v0.6.3 adds the node:vm module for running code in controlled JavaScript contexts and fixes node:tls and node:http so socket.io and mongodb authentication work. bun test gains test.todo(), toBeCloseTo(), per-test timeouts and lifecycle hooks via --preload.
- [Bun v1.4.1](https://swe.quest/articles/bun-v1-4-1-d28e00ae252842cf.md): Bun · 2026-09-04 · Medium · 38 min read · JavaScript, Runtimes & VMs, Performance engineering, Build systems, Networking
  Bun v1.4.1 fixes 202 issues and ships runtime, install and bundler improvements.
- [Bun v0.8.1](https://swe.quest/articles/bun-v0-8-1-ecd25e5146563167.md): Bun · 2023-08-26 · Medium · 6 min read · Runtimes & VMs, JavaScript, Performance engineering, Memory management
  Bun v0.8.1 adds unix domain socket support to Bun.serve() via a new \`unix\` option and fixes a 2.8x request-body throughput regression from v0.8.0 (about 38.6k to 110k req/s).
- [Bun v0.7.0](https://swe.quest/articles/bun-v0-7-0-d3096f46f4bdb50f.md): Bun · 2023-07-21 · Medium · 10 min read · JavaScript, Runtimes & VMs, Concurrency
  Bun v0.7.0 focuses on Node.js compatibility: it can now run \`vite dev\` (experimentally, via \`bun --bun\` to override the node shebang), supports Web \`Worker\` threads with \`postMessage\` and \`structuredClone()\`, and implements \`AsyncLocalStorage\` from \`node:async\_hooks\` as a step toward Next.js support.
- [Bun v0.2.2](https://swe.quest/articles/bun-v0-2-2-758afa2db2ef7788.md): Bun · 2022-10-27 · Medium · 5 min read · JavaScript, Runtimes & VMs, Networking
  Bun v0.2.2 adds a TCP/TLS socket API for clients and servers.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
