Skip to content
Commit Detail

Commit b433e4a

Author
Kenton Varda <kenton@cloudflare.com> 2025-12-20 11:40:36 -0600
Parents
e89ed92
Tree
77aa29c
Intorduce new JsValue.ExternalPusher interface to replace StreamSink.

The design of `StreamSink` makes it fairly complicated and somewhat inefficient to implement. For example:

* It requires the use of `setPipeline()` so that the caller can start to enable promise pipelining on the `StreamSink` before it actually returns results.
* Every call must create a `resultsStreamSink` object in advance, before it knows if there will be any streams in the results.
* Generally there's just a lot of contortions involved in supporting it.

It occurred to me that a different design is possible: one where we have an object that is created *per-IoContext* (instead of per-call) which can be used to "push" values into that IoContext, so that they can then be referenced as externals by subsequent JsValues.

This commit introduces that design, including specifying how it would work to implement `ReadableStream`. Subsequent commits will actually implement this design.

Eventually, after everyone in production is updated to understand and then use the new design, we can deprecate and remove StreamSink, thus cleaning up all the mess it created.

Files changed

2 files changed~2 modified