Skip to content

SYSTEM Cited by 1 source

LiteReadable

LiteReadable is Vercel's custom array-based buffer replacement for Node.js's built-in Readable, used inside fast-webstreams to back byte-oriented ReadableStream({type: 'bytes'}) instances. Disclosed 2026-04-21 in sources/2026-04-21-vercel-we-ralph-wiggumed-webstreams-to-make-them-10x-faster.

Why it exists

Node's Readable is a full-featured, EventEmitter-based, internally-queued stream class. For the specific React Flight byte-stream pattern — new ReadableStream({type: 'bytes'}) with start() capturing the controller and external controller.enqueue(Uint8Array) calls — most of Node Readable's machinery is unused while its per-construction overhead is measurable.

React Flight creates hundreds of byte streams per request. A ~5 µs saving per construction compounds.

Design

  • Array-based buffer, not a ring buffer or linked list.
  • Direct callback dispatch, not EventEmitter. Avoids the on/emit cost per data event.
  • Pull-based demand, so the buffer fills when asked, not ahead of consumption.
  • BYOB (bring-your-own-buffer) reader support — see concepts/byob-reads. Consumers pass in a pre-allocated ArrayBuffer view; data is copied once into consumer memory, not into an intermediate buffer first.
  • ~5 µs less per construction vs Node's Readable, per the 2026-04-21 post.

Measured impact

On the React Flight pattern (start + enqueue), native Web Streams throughput is ~110 MB/s at 1 KB chunks; fast-webstreams with LiteReadable hits ~1,600 MB/s — a 14.6× gap. Per the post: "it costs about 5 microseconds less per construction. That matters when React Flight creates hundreds of byte streams per request."

Not a standalone library

LiteReadable is an internal component of fast-webstreams, not a public export or replacement for stream.Readable in general. The design is specifically tuned to the byte-stream + enqueue-externally pattern. General-purpose Node Readable use cases (object mode, backpressure-heavy pipes, pause/resume semantics) are left to the built-in stream.Readable.

Seen in

Last updated · 476 distilled / 1,218 read