We Ralph Wiggumed WebStreams to make them 10x faster

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

Vercel profiled Next.js server rendering and found that WHATWG WebStreams (ReadableStream, WritableStream, TransformStream) were a major bottleneck due to per-chunk Promise allocations, microtask queue hops, and object overhead. They built `fast-webstreams`, a drop-in replacement that routes operations through Node.js's optimized `pipeline()` internally. Key optimizations include: zero-Promise piping by deferring pipeline construction until the full chain is known, synchronous resolution when data is already buffered, and a minimal `LiteReadable` for byte streams. Benchmarks show 10-14x throughput gains for common patterns—630 MB/s native vs ~6,200 MB/s for pipeThrough chains, and 110 MB/s vs 1,600 MB/s for the React Flight byte stream pattern. The library passes 1,100 of 1,116 Web Platform Tests. The work is also being contributed upstream to Node.js via a PR from Matteo Collina that adds fast paths directly to Node's native WebStreams implementation.

•11m read time•From vercel.com
Post cover image
Table of contents
The problemWhat we builtBenchmarksSpec complianceHow we are deploying thisThe right fix is upstreamWhat we learned the hard wayWe built most of fast-webstreams with AITry it
1 Comment

Sort: