workerd / writable
AGENTS.md8.8k starsChanged 9 months agoApache-2.0View on GitHub
An informal specification of the JS-backed writable stream classes as implemented in workerd, derived from — and kept in lockstep with — the test suite in this directory. The tests are the normative artifact. Both the C++ implementation (src/workerd/api/streams/writable.{h,c++} over standard.c++'s WritableImpl/WritableStreamJsController) and the TypeScript implementation (src/per_isolate/webstreams/writable.ts, behind typescript_implemented_streams) are covered. The suite COMPLEMENTS WPT (//src/wpt:streams runs writable-streams/ against both implementations): behaviors WPT already asserts identically on both sides are not duplicated here. The WPT C++ expectedFailures for writable-streams/ in…
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
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
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/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/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
We split this AGENTS.md into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
NOT change the outcomes below).
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
WritableStream, WritableStreamDefaultWriter, WritableStreamDefaultController
An informal specification of the JS-backed writable stream classes as
implemented in workerd, derived from — and kept in lockstep with — the test
suite in this directory. The tests are the normative artifact. Both the
C++ implementation (src/workerd/api/streams/writable.{h,c++} over
standard.c++'s WritableImpl/WritableStreamJsController) and the
TypeScript implementation (src/per_isolate/webstreams/writable.ts, behind
typescript_implemented_streams) are covered.
The suite COMPLEMENTS WPT (//src/wpt:streams runs writable-streams/
against both implementations): behaviors WPT already asserts identically on
both sides are not duplicated here. The WPT C++ expectedFailures for
writable-streams/ in src/wpt/streams-test.ts (aborting ×11,
bad-strategies ×2, bad-underlying-sinks ×2, constructor ×2, floating-point
×3, start ×1) seeded the ledger below; probing showed several "failures"
(the aborting.any family) come from testharness strictness while the
underlying behaviors are parity — those parity pins live in
abort-matrix.js.
The startedness model (root of several divergences)
C++ invokes sink algorithms synchronously from writer.write()/close()
(without pedantic_wpt; with it they are deferred a microtask, which does
NOT change the outcomes below). TypeScript follows the spec's [[started]]
gating: no sink hook runs until the start promise has settled in a
microtask. A synchronous write(); abort(); sequence therefore finds the
write already in flight under C++ (the sink runs; the write fulfills) but
still queued under TypeScript (the sink never runs; the write rejects with
the abort reason).
Divergence ledger (C++ vs TypeScript)
| # | Area | C++ | TypeScript | Pinned in |
| 1 | invalid highWaterMark at ctor | TypeError (jsg uint64 conversion messages) | RangeError "Invalid highWaterMark" (spec) | highWaterMarkValidated |
| 2 | sink.type validation | ignored (pedantic_wpt: RangeError) | RangeError "Invalid underlying sink type" (spec) | sinkTypeValidation |
| 3 | argument conversion order | sink dictionary first (sink.write, hwm, size) | strategy first (size, hwm ×2, sink.write; spec) | argumentConversionOrder |
| 4 | ready at construction (no backpressure) | pending after a microtask, fulfills on a later turn | fulfilled within a microtask (spec) | readyFulfillTiming |
| 5 | sync start() throw | captured; stream errored, writes reject | escapes the constructor (spec) | newWritableStreamStartError |
| 6 | abort() on an errored stream | rejects with the stored error | fulfills with undefined (spec) | newWritableStreamAbortError |
| 6b | concurrent aborts | a fresh promise per abort() call | the same promise for both (spec); both fulfill undefined | concurrentAbortPromiseIdentity |
| 7 | startedness (see above) | sync write→abort: sink runs, write fulfills; a same-turn mutation/detach/resize of the chunk's buffer after write() is NOT observed by the sink | write still queued: rejected with abort reason; the buffer change IS observed | writableStreamAbortWhileWriting, writableStreamAbortWriteClosePending, writableStreamPromisesResolvedInOrder, writableStreamCloseThrowRejectsPromises, abortRejectsOutstandingWriteWithReason, buffer-lifecycle.js (chunkMutationVisibility, detachAfterWriteTiming, resizableGrowAfterWrite, resizableShrinkOutOfBounds) |
| 8 | close hook racing an immediate abort | close hook runs; close+abort reject with its error | close still queued: hook never runs, close rejects with abort reason, abort fulfills | writableStreamCloseThrowRejectsPromises |
| 9 | queue totals | size() → uint64 (fractions truncate; NaN/negative/±Infinity → TypeError, also for a write after close(), which with an earlier write queued rejects the close too); desiredSize narrowed through int (wraps past 2^31) | double arithmetic per spec; invalid size → RangeError "Invalid chunk size", checked only on enqueue: a write after close() rejects alone and the close completes | floatingPointQueueTotals, fractionalSizeTruncation, invalidSizeReturnRejects, invalidSizeAfterCloseRejectsOnlyTheWrite |
| 10 | signal.reason for reasonless abort() | undefined (pedantic_wpt: AbortError DOMException) | AbortError DOMException (spec) | abortSignalReason |
| 11 | desiredSize while erroring | queue accounting value (pedantic_wpt: null) | null (spec) | desiredSizeWhileErroring |
| 12 | non-callable size / released-writer messages | jsg dictionary / "This WritableStream writer has been released." | TS validator / "This writer has been released" | nonCallableSizeThrows, releaseLockInsideSize |
| 13 | releaseLock() with writes still queued | cancels them: queued writes reject with the released-writer error and their chunks are dropped (a C++ deviation — the source of its WPT piping/flow-control release-then-pipe expectedFailures) | spec: release rejects only ready/closed; queued writes stay in [[writeRequests]] and drain on the sink's schedule (a new writer can relock and they still complete — WPT flow-control pins that; behind a never-settling in-flight write they wait forever on backpressure) | cancelWriteOnReleaseLock |
| 14 | when a promise returned by start() starts the stream | adopts it: a write queued during start reaches the sink before the first marker chained on it | spec (Node agrees): a new promise is resolved with it, so the write reaches the sink after the second marker, whether it was fulfilled on return or later | startPromiseSettledInNewPromise |
Parity worth noting (probed, pinned): the whole in-flight abort matrix —
abort-before-start reason identity on ready/closed, errored-state reason
identity, sink abort suppressed after a bad-strategy error or a
pre-existing controller error (including while a write is in flight),
in-flight write finishing with rejection during abort, an abort during a
slow in-flight write leaving the write to FULFILL, both orders of
abort()×controller.error() with a fulfilling in-flight write, and the
abort-first order with a rejecting write; sink abort waits for in-flight
start/write/close
(abort-matrix.js, writableStreamAbortTiming,
errorRaceWithCloseWritable); sink hook getters read exactly once at
construction; a later sink write returning a rejected promise rejects
that write, a REPLACED ready, and closed with the sink's error; sink
write/close never run after a start() throw, however the failure
surfaced; ready is replaced as soon as desiredSize reaches 0; a detached
ArrayBuffer is an acceptable chunk (byteLength 0); a coercing
{valueOf} highWaterMark is accepted via ToNumber; the user size() runs
with an undefined receiver and one argument; reentrant writer.write()
from size() enqueues the inner chunk first; size() is never consulted
for doomed writes (the TS sinks' willAcceptWrite invariant); a patched
Object.prototype.then getter never fires while settling writer
promises (they resolve with undefined).
Compatibility flags
| Flag (enable date) | Pinned in main cells | Unflagged side guarded by |
streams_enable_constructors (2022-11-30) | yes (the suite's subject) | writable-cpp-legacy cell: ctor throws a flag-pointing Error; WritableStreamDefaultController global absent |
capture_async_api_throws (2022-10-31) | yes | writable-cpp-legacy-writer cell: double close throws synchronously ("Cannot close a writer that is already being closed") |
writable_stream_spec_compliant_writer (2026-03-24) | yes | writable-cpp-legacy-writer cell: releaseLock() inside size() does not doom the write; release leaves a resolved ready in place |
workers_api_getters_setters_on_prototype, set_tostring_tag | yes | generic placement/branding; identity suite legacy cell |
internal_writable_stream_abort_clears_queue (2024-09-02) | NOT pinned | internal-impl only (internal.c++); unreachable from JS-backed WritableStream |
pedantic_wpt (dateless opt-in) | writable-cpp-pedantic cell | flag-off sides are the C++ columns of ledger #2/#10/#11 |
Assertion catalogue
| Module | Asserts |
api-surface.js | writable globals exist; controller not constructable; bare ctor works (full IDL shape is WPT's) |
construction.js | ledger #1–#5, #12; fractional and ToNumber-coerced hwm accepted |
sink-algorithms.js | ledger #14; which sink hooks run with what arguments/controller; sync+async hook errors surface on writer promises (#5, #6); size() consulted per write; hook getters read once; second-write rejection fan-out; hooks silent after start throw |
write-semantics.js | chunk identity (subarrays, any JS value via Object.is); multiple pending writes; settlement ordering incl. under abort (#7); queued-write fate at releaseLock (#13) |
buffer-lifecycle.js | chunks never copied/validated: already-detached AB accepted (byteLength 0); post-write() mutation, detach, resizable grow, and shrink-out-of-bounds all observed per the startedness model (#7); size() runs inside write() so queue totals are immune to later detach |
close-semantics.js | close-throw promise fan-out vs abort (#7, #8); double close rejects TypeError |
abort-semantics.js | migrated abort lifecycle: reason propagation, signal event, persistent errored state, in-flight sequencing, outstanding-write startedness, terminal-state interactions (#7) |
abort-matrix.js | probed parity matrix (see above), including controller-error races and sink-hook suppression + signal reason (#10) + concurrent-abort identity (#6b) |
backpressure.js | desiredSize accounting/recovery; ready replaced at capacity; WPT floating-point scenarios and invalid sizes, incl. after close() (#9); erroring desiredSize (#11) |
reentrancy.js | size()-reentrant write ordering; releaseLock inside size (#12; flag-gated, cf. legacy-writer); controller.error inside write hook; doomed-write size skip; size receiver/arity |
then-interceptors.js | then-getter never fires on writer promise settlement |
gc.js | pending write survives gc() with all user refs dropped (--expose-gc) |
legacy-ctor-gate.js | fully-unflagged: ctor Error + absent controller global |
legacy-writer.js | pre-flag writer semantics (see Compatibility flags) |
data-volumes.js | write-side volumes: 4096 × 16 B writes, single 1 MiB write, 1 MiB / 8 MiB chunked with writer.ready honored; the sink verifies the continuous prime-modulus pattern as chunks arrive |
pollution.js | prototype pollution neither implementation observes: Object.prototype resolvers never reach the writer's settled ready/closed promises; omitted dictionaries read nothing from Object.prototype |
which-impl.js | implementation + pedantic detection |
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.

