workerd / readable
AGENTS.md8.8k starsChanged 9 months agoApache-2.0View on GitHub
Informal specification of the value-oriented ReadableStream as implemented in workerd, derived from — and kept in lockstep with — this suite. The tests are the normative artifact. Byte streams (type:'bytes', BYOB) belong to the readable-byte suite; the pipeTo/ pipeThrough matrix belongs to piping/. The suite COMPLEMENTS WPT (//src/wpt:streams). Probing the C++ expectedFailures showed many root-cause to a handful of construction divergences (hwm Infinity rejection, validation order) rather than behavioral gaps; the reentrancy family is mostly parity at finite hwm.
Trending
Quiet since August.thin dataabout the whole repository
Who's talking about cloudflare/workerd
- A Hacker News story“OS Workerd, Cloudflare's JavaScript/WASM Runtime”Hacker News · Sep 27, 2022 · 27 points
- withastro/astro“Cloudflare adapter returning [object Object]”GitHub · Oct 10, 2025 · 18 reactions
- supabase/supabase-js“The 'cache' field on 'RequestInitializerDict' is not implemented - Cloudflare Workers”GitHub · Mar 28, 2024 · 16 reactions
- nodejs/node“src: improve buffer.transcode performance”GitHub · Aug 1, 2024 · 13 reactions
- NixOS/nixpkgs“Package request: workerd”GitHub · Nov 12, 2024 · 12 reactions
The biggest 5 of 12 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 12
Talked about on GitHub, Bluesky and Hacker News (12 times).
On GitHub · 6
- Oct 10, 2025Cloudflare adapter returning [object Object] — withastro/astro18 reactions · 15 comments
- Mar 28, 2024The 'cache' field on 'RequestInitializerDict' is not implemented - Cloudflare Workers — supabase/supabase-js16 reactions · 24 comments
- Aug 1, 2024src: improve buffer.transcode performance — nodejs/node13 reactions · 26 comments
- Nov 12, 2024Package request: workerd — NixOS/nixpkgs12 reactions · 8 comments
- Feb 19, 2024Add Curve25519 — w3c/webcrypto9 reactions · 16 comments
1 more on GitHub
- Nov 3, 2025Optimize TextEncoder::encode — nodejs/performance7 reactions · 33 comments
On Bluesky · 4
- Mar 24, 2026workerd : le runtime JavaScript/Wasm open source de Cloudflare Workers — @news.humancoders.com4 likes and reposts
- Aug 22, 2026Current status: trying to build github.com/cloudflare/w... on various sandbox providers — @jeremymorrell.dev1 likes and repost
- Mar 24, 2026workerd : le runtime JavaScript/Wasm qui propulse Cloudflare Workers est maintenant open source. Basé sur les standards web, il permet… — @humancoders.com1 likes and repost
- Nov 5, 2024Technically workers are open source github.com/cloudflare/w... — @userops.bsky.social1 likes and repost
On Hacker News · 2
- Sep 27, 2022OS Workerd, Cloudflare's JavaScript/WASM Runtime27 points · 2 comments
- Oct 5, 2023Cloudflare workers is adopting Ada URL parser2 points
In this repository61 other files it gives its agents.
- AGENTS.mdAGENTS.md
- build/AGENTS.mdAGENTS.md
- src/cloudflare/AGENTS.mdAGENTS.md
- src/node/AGENTS.mdAGENTS.md
- src/per_isolate/AGENTS.mdAGENTS.md
- src/per_isolate/crypto/AGENTS.mdAGENTS.md
- src/per_isolate/webfs/AGENTS.mdAGENTS.md
- src/per_isolate/webstreams/AGENTS.mdAGENTS.md
- src/pyodide/AGENTS.mdAGENTS.md
- src/rust/AGENTS.mdAGENTS.md
- src/rust/cxx/AGENTS.mdAGENTS.md
- src/tests/node/AGENTS.mdAGENTS.md
- src/tests/node/http-client/AGENTS.mdAGENTS.md
- src/tests/node/http-server/AGENTS.mdAGENTS.md
- src/tests/node/net/AGENTS.mdAGENTS.md
- src/tests/node/stream/AGENTS.mdAGENTS.md
- src/tests/streams/AGENTS.mdAGENTS.md
- src/tests/streams/cache/AGENTS.mdAGENTS.md
- src/tests/streams/compression/AGENTS.mdAGENTS.md
- src/tests/streams/digest/AGENTS.mdAGENTS.md
- src/tests/streams/encoding/AGENTS.mdAGENTS.md
- src/tests/streams/formdata/AGENTS.mdAGENTS.md
- src/tests/streams/htmlrewriter/AGENTS.mdAGENTS.md
- src/tests/streams/identity/AGENTS.mdAGENTS.md
- src/tests/streams/inspect/AGENTS.mdAGENTS.md
- src/tests/streams/iocontext/AGENTS.mdAGENTS.md
- src/tests/streams/piping/AGENTS.mdAGENTS.md
- src/tests/streams/r2-patterns/AGENTS.mdAGENTS.md
- src/tests/streams/readable-byte/AGENTS.mdAGENTS.md
- src/tests/streams/scaling/AGENTS.mdAGENTS.md
- src/tests/streams/sockets/AGENTS.mdAGENTS.md
- src/tests/streams/strategies/AGENTS.mdAGENTS.md
- src/tests/streams/transform/AGENTS.mdAGENTS.md
- src/tests/streams/writable/AGENTS.mdAGENTS.md
- src/workerd/api/AGENTS.mdAGENTS.md
- src/workerd/api/crypto/AGENTS.mdAGENTS.md
- src/workerd/api/node/AGENTS.mdAGENTS.md
- src/workerd/api/streams/AGENTS.mdAGENTS.md
- src/workerd/io/AGENTS.mdAGENTS.md
- src/workerd/jsg/AGENTS.mdAGENTS.md
- src/workerd/server/AGENTS.mdAGENTS.md
- src/workerd/util/AGENTS.mdAGENTS.md
- types/AGENTS.mdAGENTS.md
- bazel-test-hygieneSkill
- commit-categoriesSkill
- dad-jokesSkill
- find-and-run-testsSkill
- identify-reviewerSkill
- investigation-notesSkill
- kj-styleSkill
- markdown-draftsSkill
- parent-project-skillsSkill
- pr-review-guideSkill
- receiving-code-reviewSkill
- rust-reviewSkill
- ts-styleSkill
- update-v8Skill
- wd-test-formatSkill
- workerd-api-reviewSkill
- workerd-safety-reviewSkill
- The first 60 shown.
The file
Files
ReadableStream (default), ReadableStreamDefaultReader/Controller
Informal specification of the value-oriented ReadableStream as implemented in workerd, derived from — and kept in lockstep with — this suite. The tests are the normative artifact. Byte streams (type:'bytes', BYOB) belong to the readable-byte suite; the pipeTo/ pipeThrough matrix belongs to piping/.
The suite COMPLEMENTS WPT (//src/wpt:streams). Probing the C++
expectedFailures showed many root-cause to a handful of construction
divergences (hwm Infinity rejection, validation order) rather than
behavioral gaps; the reentrancy family is mostly parity at finite hwm.
Divergence ledger (C++ vs TypeScript)
| # | Area | C++ | TypeScript | Pinned in |
| 1 | garbage underlyingSource | accepts null, rejects numbers | rejects null (spec), accepts numbers | garbageSourceValidation |
| 2 | ctor argument conversion order | source.type, hwm, size | strategy size, hwm, then source.type (spec) | argumentConversionOrder |
| 3 | invalid hwm (-1/NaN) + Infinity | TypeError; Infinity REJECTED (integer conversion) — root cause of many WPT reentrant/errors failures | RangeError; Infinity accepted (spec) | highWaterMarkValidated |
| 4 | pull counts (hwm 1, enqueue-in-pull) | 1,1,3 — first read served from queue without pull, deferred pulls batch | 1,2,3 (spec: pull after start and every read) | pullCountShape |
| 5 | pull on reading the LAST queued chunk | no pull | pulls (spec) | pullOnLastChunkRead |
| 6 | sync start() throw | captured; stream errored | escapes constructor (spec) | syncStartThrow |
| 7 | reader.closed after releaseLock | SAME promise object, settled state kept | REPLACED with TypeError 'This reader has been released' (spec) | closedReplacedOnReleaseAfterClose/...Error |
| 8 | size() errors stream then throws/returns Infinity | enqueue swallows | enqueue rethrows / RangeError (spec) | sizeErrorsStreamThenThrows/...ReturnsInfinity |
| 9 | invalid size() return (NaN/-1) | enqueue returns normally, stream errored (ds null); DEFECT: subsequent read() spins the isolate synchronously (unpinnable) | enqueue throws RangeError 'Invalid chunk size', reads reject same (spec) | invalidSizeReturnValue |
| 10 | queue total-size math | integer-ish: saturates (maxSafeInt shape -2,-1,1,0), fractional sizes truncate to 0; DEFECT: reading a fractional-size chunk spins the isolate | full double-precision per spec (all four WPT shapes) | queue-math.js (3 tests) |
| 11 | tee cancel composite | source cancel gets ONLY the pair-completing branch's reason; first branch's cancel promise fulfills immediately | AggregateError of every branch's reason, in the order they cancelled (identity; intentional divergence from spec's array — tee is N consumers on one queue, the last to leave cancels the source); LONE branch cancel promise PENDS until the other cancels (spec) — never await a lone branch cancel | teeCancelReasonComposite, teeCancelReverseOrder |
| 12 | from(string) | iterates per code unit ['h','i'] | single chunk ['hi'] (spec: throws — both diverge from spec) | fromString |
| 13 | async-iterator prototype | exposes constructor + next/return | next/return only | iteratorPrototypeShape |
| 14 | read() inside size() | in-flight chunk fed DIRECTLY to the reentrant read | chunk queued; the NEXT enqueue bypasses the queue into the reentrant read (spec) — deliveries swapped | readInsideSize |
| 15 | adopted body stream lock after consumption | released | kept locked | bodyIdentityAndLockCoupling |
| 16 | then-getter fires during a read cycle | 1 (harness context) | 2 | thenGetterFireCountOnRead |
| 17 | close-twice / enqueue-after-close / size-not-function / from-return validation messages | own texts | own texts | closeTerminality, sizeMustBeFunction, fromReturnValidationMessages |
| 18 | error() while a close() is still pending (chunks queued) | ignored: the requested close is final, desiredSize is already 0 and the chunks drain to a clean close | desiredSize is hwm minus the queued chunks (-1) until the error, then the stream errors (spec: close() only requested the close, the state is still "readable"): chunks discarded, reads/closed reject, desiredSize null | errorAfterCloseWithQueuedChunk |
| 19 | controller held, stream dropped and collected | the controller does not keep its stream alive: its consumer leaves the queue, enqueue() drops the chunk silently, desiredSize stays at the high-water mark (no backpressure for a producer holding only the controller) | the controller references the stream (spec [[stream]]): enqueues count, desiredSize 4 → 0 | controllerOnlyHeldStreamLiveness |
| 20 | pull() after both tee branches are collected (controller held) | keeps pulling for consumers that no longer exist; DEFECT: a source that enqueues on every pull runs until the stream closes | the source is released: pull() is never called again (the parity half — enqueue drops, desiredSize at the high-water mark, close() as ever — is teeBranchesCollected) | teeBranchesCollectedPullStops |
| 21 | body consumption of a TransformStream readable that delivers more than its declared expectedLength | returns everything (consumption ignores the declaration) | rejects with RangeError 'stream delivered more bytes than its declared expectedLength' and cancels the readable with it, which errors the writable (the declaration is the exact-total contract the byte and native sources already enforce) | transformExpectedLengthOverflow |
| 22 | async-iterator next() interleavings where WebIDL clears the ongoing promise | every call strictly serialized: a next() from a continuation registered on an earlier next() still waits for the queued ones, and one queued behind return() reports done; after a next() rejects, later ones reject with the same error | spec: that next() reads ahead of the queued one (n2 'c', n3 'b') and ahead of a queued return() (reads data; the return still cancels); after a next() rejects, the iterator is finished and later ones report done (this last shape is among the WPT async-iterator.any C++ expectedFailures; the read-ahead shapes are derived from the WebIDL algorithm) | nextFromEarlierContinuationReadsAhead, nextFromEarlierContinuationBeatsReturn, nextAfterRejectedNextIsDone |
| 23 | when a promise returned by start() starts the stream | adopts it: the first pull runs before the first marker chained on it | spec (Node agrees): a new promise is resolved with it, so the pull runs after the second marker, whether it was fulfilled on return or later | startPromiseSettledInNewPromise |
Parity worth noting (probed, pinned): pull serialization (never re-entered); pull/async-start rejection identity; error-undefined preserved through closed; error() twice / after a completed close are no-ops (a close still pending is ledger #18); desiredSize lifecycle (1 → 0 close, null error, 0 cancel) and enqueue-skips-queue-with-pending-read; cancel-with-pending-pull; cancel reason identity + once; locked-stream cancel rejects without running the hook; tee error propagation identity to both branches, tee pull-per-read shape, tee backpressure following the slowest branch (a push source stalls both branches on an idle one; the spec's per-branch queues would not), tee after partial read; the tee-reentrancy crash regressions; from() cancel plumbing identity through return(); async-iterator protocol interleavings (return/next no-await; the WebIDL ongoing-promise shapes are #22); chunks held BY REFERENCE (mutation visible, identity) + detach-while-queued observed; and the ENTIRE integration surface except #15 and #21: body chunk normalization (messages included: 'This ReadableStream did not return bytes.'), a failing consumer cancelling the source with its error (the cancel's own rejection then wins) and leaving the stream locked, chunks collectible while consumption runs (the bytes are copied out), exact assembly across odd chunk sizes, disturbed-into-Response TypeError, locked-into-Response ACCEPTED, clone-both-read, cancel-body-then-consume 'Body has already been used', readAll small/big/failed paths, SELF fetch round-trips (fetch body + Request body, the workerd#5113 shapes).
The ts cell additionally sets the internal-testing
expose_draining_reader flag, installing the
ReadableStreamDrainingReader global — the bulk-drain conduit the C++
bridge drives to consume TypeScript streams (conduit basics in the
identity suite's draining-reader.js). No such global exists under the
C++ implementation; draining-reader.js asserts both sides.
Compatibility flags
| Flag | Pinned in main cells | Unflagged side |
streams_enable_constructors (2022-11-30) | yes (the suite's subject) | readable-cpp-legacy cell: ctor and .from() throw plain Errors naming the flag; ReadableStreamDefaultController not exposed; native-backed streams (Response bodies) fully usable incl. tee() |
transformstream_enable_standard_constructor | yes (tee-reentrancy drives tee through TransformStreams) | transform suite's legacy cells |
capture_async_api_throws, workers_api_getters_setters_on_prototype, set_tostring_tag, fixup-transform-stream-backpressure, writable_stream_spec_compliant_writer | yes | other suites' legacy cells |
pedantic_wpt (dateless opt-in) | readable-cpp-pedantic cell | zero observable deltas on this suite's probed surface (cpp == pedantic in every probe) |
Module map
| Module | Coverage |
api-surface.js | globals, controller not constructable, getReader modes, locked lifecycle |
construction.js | ledger #1-#3, default hwm 1 |
source-algorithms.js | ledger #4-#6, #23, pull serialization, rejection identity, cancel-with-pending-pull |
controller.js | desiredSize accounting/terminal states, error idempotence, close terminality (#17), close-drains-queue, error during a pending close (#18) |
reader.js | read ordering, releaseLock, closed replacement (#7), undefined error, reader.cancel, reader swap |
cancel.js | reason identity, locked-cancel, hook rejection identity, queue discard |
bad-strategies.js | ledger #8, #9, size-not-function |
queue-math.js | ledger #10 (WPT float shapes; cpp bounded observables only) |
tee.js | migrated edge cases + error propagation + cancel composite (#11) + pull-per-read + slowest-branch backpressure |
tee-reentrancy.js | the three C++ push-loop crash regressions (from api/streams/streams-test.js) |
from.js | 11 migrated + fromString (#12) + return validation messages |
async-iteration.js | 7 migrated + no-await interleavings + proto shape (#13) + ongoing-promise interleavings (#22) |
reentrancy.js | enqueue/close/cancel-in-size (parity) + read-in-size (#14; guard the size() or C++ captures every later chunk) |
buffer-lifecycle.js | chunk by reference, detach observed |
integration-body.js | readAll family, normalization (incl. detached and out-of-bounds views, DataViews included, SharedArrayBuffer-backed views, resizable-extent pinning), clone, cancel-then-consume, SELF round-trips |
integration-body-failures.js | consumer-side failures cancel the source with the error (every consumer; the cancel's rejection replaces it; nothing to cancel once the closing batch is in), leave the stream locked and stop pulls; TransformStream expectedLength overflow (#21) and exact delivery |
integration-body-memory.js | body consumption copies bytes out as they arrive: chunk buffers are collectible mid-consumption (WeakRef + gc()), ~2.5 MiB of pseudo-random chunk sizes assembles exactly as bytes and as text, one chunk wider than a 1 MiB collection block assembles exactly, a declared-length byte body is exact |
integration-locked-disturbed.js | disturbed rejected, locked accepted, body identity + lock coupling (#15) |
gc.js | pending read + async iteration survive gc(); a controller held with its stream collected (ledger #19); both tee branches collected while the controller is held: enqueue() drops without retaining (WeakRef-checked, backlog included), desiredSize at the high-water mark, close() then enqueue() as ever, and pull() stops (ledger #20); one branch cancelled and the other collected, observed in the gc()'s own job (before finalization callbacks): the controller's queries drop the consumer themselves |
then-interceptors.js | ledger #16; a then getter that cancels tee branches while a read result settles (during enqueue() and close(), one branch or two of three): the other branches' pending reads still resolve and their backlog still counts toward desiredSize |
legacy-constructors.js | the unflagged cell (see flags table) |
draining-reader.js | TS only (C++ cell asserts the global's absence): a queued backlog plus the close sentinel swept in ONE batched read; value chunks pass through UNTOUCHED (object identity); pull-driven yields per read with EOF as a separate empty batch; expectedLength undefined; error/cancel propagation; lock exclusivity and release |
data-volumes.js | value-stream volume axes: 4096-chunk counts, a 1 MiB single string chunk, 8 MiB aggregate (128 × 64 KiB), and 1 MiB through tee on both branches — every chunk index-encoded |
pollution.js | prototype pollution neither implementation observes: a patched array iterator or replaced Number global leaves bodies intact; a patched controller error() still errors the stream; omitted dictionaries read nothing from Object.prototype; @@asyncIterator shape (TS: the values() function object, per WebIDL; C++: a separate function) and for-await ignoring a patched values() |
Consumed sources: streams-async-iterator-test.js (deleted), streams-tee-edge-cases-test.js (value half), streams-test.js (from/ readAll/reader/cancel families; BYOB+writable+TransformStream tests remain), api/streams/streams-test.js (tee-reentrancy trio + ResponseTextLargeBody), ts-webstreams-test.js (three parity body tests; its TS-identity assertions remain). streams-js-test.js is deliberately untouched: its tests interleave value and byte sections, so its value halves move when the readable-byte suite consumes the byte halves.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

