Skip to content

Commit f65c77c

Browse files
docs(http): clarify serializeStream return type and granularity
The Handler Interface table typed `serializeStream` as returning a WHATWG `ReadableStream`. Verified against harper origin/main: every built-in handler returns a Node.js `Readable` (`streamAsJSON` -> `JSONStream extends Readable`, `Readable.from(...)`, `EncoderStream`, `toCsvStream`), and the call site in `server/serverHelpers/contentTypes.ts` pipes the return value through `createBrotliCompress()` and hands it to the HTTP layer as the response body. Also record the granularity: `serializeStream` is invoked once per response with the entire iterable, and only when the response body is an iterable or async iterable. Per-chunk serialization is `serialize`, which the streaming handlers call for each message. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent f15f062 commit f65c77c

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

reference/http/api.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,12 @@ contentTypes.set('text/xml', {
434434
435435
### Handler Interface
436436
437-
| Property | Type | Description |
438-
| ----------------------- | ----------------------------------------- | ----------------------------------------------------------------------------------------- |
439-
| `serialize(data)` | `(any) => Buffer \| Uint8Array \| string` | Serialize data for a response |
440-
| `serializeStream(data)` | `(any) => ReadableStream` | Serialize as a stream (for async iterables or large data) |
441-
| `deserialize(buffer)` | `(Buffer \| string) => any` | Deserialize an incoming request body. String for `text/*` types, Buffer for binary types. |
442-
| `q` | number (0–1) | Quality indicator for content negotiation. Defaults to `1`. |
437+
| Property | Type | Description |
438+
| ----------------------- | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
439+
| `serialize(data)` | `(any) => Buffer \| Uint8Array \| string` | Serialize data for a response |
440+
| `serializeStream(data)` | `(any) => Readable` | Serialize a streaming response body. Called once per response with the whole iterable (not once per chunk), and only when the response body is an iterable or async iterable. Returns a Node.js [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable). |
441+
| `deserialize(buffer)` | `(Buffer \| string) => any` | Deserialize an incoming request body. String for `text/*` types, Buffer for binary types. |
442+
| `q` | number (0–1) | Quality indicator for content negotiation. Defaults to `1`. |
443443
444444
---
445445

0 commit comments

Comments
 (0)