An informal specification of the two WHATWG Encoding 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; this document indexes every specified behavior to the test that asserts it. Both the C++ implementation (src/workerd/api/streams/encoding.{h,c++}) and the TypeScript implementation (src/perisolate/webstreams/encoding.ts, behind typescriptimplemented_streams) are covered. The WPT encoding/streams/* tests already run against both implementations (//src/wpt:encoding and //src/wpt:encoding-ts), so this suite complements WPT rather than…
Multipart parsing FROM streamed bodies and FormData serialized INTO a stream body — under both stream implementations. The tests are the normative artifact. The general FormData surface (W3C API matrix, urlencoded, entry semantics) is owned by src/workerd/api/tests/ form-data-test.js; this suite owns the STREAMS interaction only. Both cells set formdataparsersupports_files so multipart file entries parse as File objects.
HTMLRewriter consuming stream bodies, producing a stream body, and reading streamed replacement content — under both stream implementations. The tests are the normative artifact. The general rewriter surface (selectors, handler types, comments/doctype/text tokens, async handlers) is owned by src/workerd/api/tests/ htmlrewriter-test.js; this suite owns the STREAMS interaction only. Unlike the api/tests rewriter files (which pin the pre-fixup behavior via original-transform-stream-backpressure), the cpp cell here runs under the MODERN fixup-transform-stream-backpressure. After the next source chunk wakes a canceled rewriter pump, C++ makes…
An informal specification of the two workerd-specific identity stream surfaces, derived from — and kept in lockstep with — the test suite in this directory. The tests are the normative artifact; this document is the index that maps every specified behavior to the test that asserts it. Both the legacy C++ implementation (src/workerd/api/streams/) and the TypeScript implementation (src/perisolate/webstreams/identity.ts, behind typescriptimplemented_streams) are covered; where they deliberately diverge, both sides are specified and pinned. Unless marked otherwise, behaviors below describe the current…
Informal specification of node:util inspect output for every stream surface, derived from — and kept in lockstep with — this suite. The tests are the normative artifact. The C++ implementation installs a custom inspect exposing lock/state internals; the TypeScript implementation has none — every stream inspects as a bare ClassName {} regardless of state, so introspection consumers lose [state], [supportsBYOB], [length], and [expectsBytes] under TS. Both sides are pinned verbatim at every lifecycle transition. The C++ cell pins, beyond the…
Module evaluation runs OUTSIDE any IoContext, and streams constructed there must work — including when later used inside requests. Migrated wholesale from streams-iocontext-test.js (itself ported from the edgeworker streams-iocontext.ew-test), plus the module-scope WritableStream pin from streams-test.js and new byte-stream and TransformStream coverage. The tests are the normative artifact. Structure note: the module-scope streams live in global-scope-streams.js together with the routing fetch handler; main.js re-exports both. Moving the constructions would change which module's evaluation performs them. Cross-request state (tests 6-8) uses…
Informal specification of stream piping as implemented in workerd, derived from — and kept in lockstep with — this suite. The tests are the normative artifact. Endpoint behaviors belong to the sibling suites (writable/, transform/, readable/, readable-byte/); identity↔ identity piping — including the circular pipeThrough pin — lives in the identity suite's pipe-integration.js. The suite COMPLEMENTS WPT (//src/wpt:streams). The C++ seeds in piping/error-propagation-forward largely root-cause to harness shapes plus ledger #5/#6 below; piping/close-propagation-backward and error-propagation-backward are DISABLED for hangs —…
R2's SDK consumes workerd streams through readAtLeast-driven BYOB loops, tees, Request clones, and TextDecoderStream. This suite pins those real-world shapes against both implementations, migrated wholesale from streams-r2-patterns-test.js. The tests are the normative artifact. The readAtLeast tail rows all follow the C++ tail contract: a close below the minimum folds the available bytes into a done=false result and a follow-up read resolves done. The remaining divergences are the tee byobRequest model (row 2, accepted) and how much an identity-stream readAtLeast takes…
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.
Informal specification of byte-oriented ReadableStreams as implemented in workerd, derived from — and kept in lockstep with — this suite. The tests are the normative artifact. Value streams live in readable/; the pipeTo/pipeThrough matrix belongs to piping/. The suite COMPLEMENTS WPT (//src/wpt:streams). Probing showed the C++ failures in readable-byte-streams/* root-cause to a few construction and pump divergences plus the close-with-partial and read-min shapes below; the releaseLock→second-reader cluster and the buffer-hazard families are behavior-parity (messages aside).
Dequeue cost stays linear in every internal queue of both streams implementations: buffered chunks, pending reads, pending pull-intos, write requests, the writable controller's chunk queue, and the identity stream's write snapshots. Each test drives one queue to 80k-160k entries (identity: 80k, over a 16x range) and asserts, through helpers.js, that the time grows by at most 4x the linear multiple of a run at 1/8 (identity: 1/16) the size. The ratio is machine-independent; the sizes sit well past the ~20k…
The readable/writable stream halves of connect() TCP sockets under both stream implementations. The tests are the normative artifact. The general Socket surface (startTls, secureTransport, DNS overrides, the connect-handler protocol, HTTP-over-socket) is owned by src/workerd/api/tests/ (http-socket-test, connect-handler-test, starttls-*); this suite owns the STREAMS interaction only. A node sidecar (echo-server.js) runs two TCP servers, their ports delivered through fromEnvironment bindings (STREAMSECHOPORT, STREAMSGREETPORT, plus SIDECAR_HOSTNAME): - echo: echoes every byte; on client half-close, flushes and ends (the client's readable reaches EOF after the…
An informal specification of the two WHATWG queuing strategy 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/readable.h) and the TypeScript implementation (src/perisolate/webstreams/strategies.ts, behind typescriptimplemented_streams) are covered. The WPT streams/queuing-strategies.any.js runs against both implementations; its 12 C++ expectedFailures in src/wpt/streams-test.ts correspond exactly to ledger entries #1–#6 below — the suite pins what the C++ side actually does where…
An informal specification of the JS-backed TransformStream 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/transform.c++ over standard.c++'s TransformStreamDefaultController) and the TypeScript implementation (behind typescriptimplementedstreams) are covered. The suite COMPLEMENTS WPT (//src/wpt:streams runs transform-streams/ against both implementations). Probing the 30+ C++ expectedFailures showed most narrow to a handful of root causes (below); several WPT "failures" (properties.any's arg counts/prototype-chain, the…
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/perisolate/webstreams/writable.ts, behind typescriptimplemented_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…
WebCrypto API + Node.js crypto C++ implementations over BoringSSL. crypto.h defines public JSG types (CryptoKey, SubtleCrypto, CryptoKeyUsageSet). impl.h defines internal CryptoKey::Impl base class with per-algorithm static ImportFunc/GenerateFunc dispatch. Algorithm files implement Impl subclasses. OSSLCALL() macro wraps all BoringSSL calls with error translation.
C++ implementations of Node.js built-in modules. Each module = JSG-bound class registered via NODEJS_MODULES(V) macro in node.h. TypeScript counterpart lives in src/node/. Tests in tests/. Naming: <module>-test.js + <module>-test.wd-test; -nodejs- infix when needing compat flags. All tests set compatibilityFlags = ["nodejscompat", "nodejscompatv2", "experimental"]. Network tests (net, tls, http) use sidecar jsbinary targets. fixtures/ has 46 PEM files for crypto. process-stdio tests use shtest with .expectedstdout/.expectedstderr. C++ unit test: buffer-test.c++ via kjtest.
Web Streams API: ReadableStream, WritableStream, TransformStream. See README.md for terse reference (classification, state machines, safety patterns). See docs/streams.md for narrative tutorial. NOTE: C++ code outside this directory does not use jsg::Ref<ReadableStream> or jsg::Ref<WritableStream> directly; it goes through the JsReadableStream / JsWritableStream abstractions in src/workerd/api/js-{readable,writable}-stream.{h,c++}, which hide which stream implementation backs a given stream (and provide JsReadableWritablePair + pipeTo/pipeThrough for abstraction-level pipelines). New C++ consumers of streams should use those abstractions, not the types defined here. Allocating the types defined here…