Skip to content
Dashboard

We Ralph Wiggumed WebStreams to make them 10x faster

CTO, Vercel

Link to headingThe problem

Link to headingWhat we built

Link to headingWhen you pipe between fast streams: zero Promises

const source = new ReadableStream({
pull(controller) {
controller.enqueue(generateChunk());
}
});
const transform = new TransformStream({
transform(chunk, controller) {
controller.enqueue(process(chunk));
}
});
const sink = new WritableStream({
write(chunk) { consume(chunk); }
});
// Internally: single pipeline() call, zero promises per chunk
await source.pipeThrough(transform).pipeTo(sink);

Link to headingWhen you read chunk by chunk: synchronous resolution

const reader = stream.getReader();
while (true) {
const { value, done } = await reader.read();
if (done) break;
// When data is buffered, the await resolves immediately
// via Promise.resolve() — no microtask queue hop
processChunk(value);
}

Link to headingThe React Flight pattern: where the gap is largest

let ctrl;
const stream = new ReadableStream({
type: 'bytes',
start(c) { ctrl = c; }
});
// As React renders each component:
ctrl.enqueue(new Uint8Array(payload1));
ctrl.enqueue(new Uint8Array(payload2));
ctrl.close();

Link to headingFetch response bodies: streams you don't construct yourself

const upstream = await fetch('<https://api.example.com/data>');
// Pipe through transforms and forward as a new Response
const transformed = upstream.body
.pipeThrough(new TransformStream({ transform(chunk, ctrl) { /* ... */ ctrl.enqueue(chunk); } }))
.pipeThrough(new TransformStream({ transform(chunk, ctrl) { /* ... */ ctrl.enqueue(chunk); } }))
.pipeThrough(new TransformStream({ transform(chunk, ctrl) { /* ... */ ctrl.enqueue(chunk); } }));
return new Response(transformed);

Link to headingBenchmarks

Link to headingCore operations

Link to headingTransform chains

Link to headingByte streams

Link to headingResponse body patterns

Link to headingStream construction

Link to headingSpec compliance

Link to headingHow we are deploying this

import { patchGlobalWebStreams } from 'fast-webstreams';
patchGlobalWebStreams();
// globalThis.ReadableStream is now the fast implementation
// fetch() response bodies are automatically wrapped
// All downstream pipeThrough/pipeTo use fast paths

Link to headingThe right fix is upstream

Link to headingWhat we learned the hard way

Link to headingWe built most of fast-webstreams with AI

Link to headingTry it