Skip to content

Commit 7f5c771

Browse files
Claude Botclaude
andcommitted
docs: Add v1.2.22 feature documentation
- Add async stack traces documentation to debugger docs - Document structuredClone performance optimizations - Add bundler minification optimization details - Document perf_hooks.monitorEventLoopDelay implementation - Add http.Server.closeIdleConnections documentation - Document interactive TTY support after stdin closes - Add WebSocket subprotocol negotiation documentation - Document WebSocket header override capabilities - Add Redis hget() method documentation - Document bun run --workspaces flag 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent db2f768 commit 7f5c771

File tree

6 files changed

+77
-3
lines changed

6 files changed

+77
-3
lines changed

docs/api/redis.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ await redis.hmset("user:123", [
132132
const userFields = await redis.hmget("user:123", ["name", "email"]);
133133
console.log(userFields); // ["Alice", "[email protected]"]
134134

135+
// Get a single field from a hash
136+
const value = await redis.hget("user:123", "name");
137+
console.log(value); // "Alice"
138+
135139
// Increment a numeric field in a hash
136140
await redis.hincrby("user:123", "visits", 1);
137141

docs/api/websockets.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,33 @@ const socket = new WebSocket("ws://localhost:3000", {
293293
});
294294
```
295295

296+
### Subprotocol negotiation
297+
298+
WebSocket clients can request specific subprotocols during the connection handshake. The server can then choose which protocol to use from the client's list.
299+
300+
```js
301+
// Request multiple protocols
302+
const ws = new WebSocket("ws://localhost:3000", ["chat", "superchat"]);
303+
304+
ws.onopen = () => {
305+
console.log(`Connected with protocol: ${ws.protocol}`); // Server's chosen protocol
306+
};
307+
```
308+
309+
### Custom headers
310+
311+
Bun allows you to set custom headers in the WebSocket constructor, including overriding standard WebSocket headers. This is useful for authentication, custom host headers, or other server requirements.
312+
313+
```js
314+
const ws = new WebSocket("ws://localhost:3000", {
315+
headers: {
316+
"Host": "custom-host.example.com",
317+
"Sec-WebSocket-Key": "dGhlIHNhbXBsZSBub25jZQ==",
318+
"X-Custom": "value"
319+
}
320+
});
321+
```
322+
296323
To add event listeners to the socket:
297324

298325
```ts

docs/bundler/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,14 @@ $ bun build ./index.tsx --outdir ./out --minify --keep-names
781781

782782
{% /codetabs %}
783783

784+
### Minification optimizations
785+
786+
The minifier applies several optimizations:
787+
788+
- **Constructor simplification**: `new Object()``{}`, `new Array(1,2)``[1,2]`
789+
- **typeof checks**: `typeof x === "undefined"``typeof x > "u"`
790+
- **Function names**: Unused function/class expression names are removed unless `--keep-names` is set
791+
784792
<!-- ### `treeshaking`
785793
786794
boolean; -->

docs/cli/run.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ will execute `<script>` in both `bar` and `baz`, but not in `foo`.
166166

167167
Find more details in the docs page for [filter](https://bun.com/docs/cli/filter#running-scripts-with-filter).
168168

169+
### `--workspaces`
170+
171+
In monorepos with workspaces, you can use the `--workspaces` flag to execute a script in all workspace packages that have the script defined.
172+
173+
```bash
174+
$ bun run --workspaces build
175+
```
176+
177+
This will run the `build` script in all workspace packages that have a `build` script defined in their `package.json`. Packages without the specified script will be skipped.
178+
169179
## `bun run -` to pipe code from stdin
170180

171181
`bun run -` lets you read JavaScript, TypeScript, TSX, or JSX from stdin and execute it without writing to a temporary file first.

docs/runtime/debugger.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,24 @@ Error: here!
323323
at moduleEvaluation (native)
324324
at <anonymous> (native)
325325
```
326+
327+
### Async stack traces
328+
329+
Bun includes asynchronous call frames in stack traces, making debugging async/await code easier:
330+
331+
```js
332+
async function foo() {
333+
return await bar();
334+
}
335+
336+
async function bar() {
337+
throw new Error("oops");
338+
}
339+
340+
await foo();
341+
// error: oops
342+
// at bar (async.js:6:9)
343+
// at async foo (async.js:2:16)
344+
```
345+
346+
The stack trace shows the complete async execution path with `async` prefixed to asynchronous frames.

docs/runtime/nodejs-apis.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ This page is updated regularly to reflect compatibility status of the latest ver
4040

4141
### [`node:http`](https://nodejs.org/api/http.html)
4242

43-
🟢 Fully implemented. Outgoing client request body is currently buffered instead of streamed.
43+
🟢 Fully implemented. Outgoing client request body is currently buffered instead of streamed. `closeIdleConnections()` is implemented.
4444

4545
### [`node:https`](https://nodejs.org/api/https.html)
4646

@@ -80,7 +80,7 @@ This page is updated regularly to reflect compatibility status of the latest ver
8080

8181
### [`node:tty`](https://nodejs.org/api/tty.html)
8282

83-
🟢 Fully implemented.
83+
🟢 Fully implemented. Includes interactive TTY support after stdin closes.
8484

8585
### [`node:url`](https://nodejs.org/api/url.html)
8686

@@ -124,7 +124,7 @@ This page is updated regularly to reflect compatibility status of the latest ver
124124

125125
### [`node:perf_hooks`](https://nodejs.org/api/perf_hooks.html)
126126

127-
🟡 Missing `createHistogram` `monitorEventLoopDelay`. It's recommended to use `performance` global instead of `perf_hooks.performance`.
127+
🟡 Missing `createHistogram`. `monitorEventLoopDelay` is implemented. It's recommended to use `performance` global instead of `perf_hooks.performance`.
128128

129129
### [`node:process`](https://nodejs.org/api/process.html)
130130

@@ -406,6 +406,10 @@ The table below lists all globals implemented by Node.js and Bun's current compa
406406

407407
🟢 Fully implemented.
408408

409+
### Performance
410+
411+
`structuredClone()` uses the same optimized serialization as `postMessage()`. For simple objects containing only primitives, it can be up to 240x faster than standard structured cloning.
412+
409413
### [`SubtleCrypto`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto)
410414

411415
🟢 Fully implemented.

0 commit comments

Comments
 (0)