[whatwg/streams] Is when pull() is called on an underlying source deterministic? (#1155)

I tried writing [a proof-of-concept fiddle](https://jsfiddle.net/jib1/omdneh0c/1) in Canary of an underlying source that manages the lifetimes of its chunks in JS (see https://github.com/w3c/mediacapture-transform/issues/56), and am seeing some surprise behaviors. Before filing a bug, I'm wondering if its to spec.

The only signal an underlying source has to work off of here seems to be the `pull` method on it.

This underlying source keeps track of `N` number of chunks it has enqueued and  calls `.close()` on the oldest chunk when it receives a `pull` of N+1 — the goal being for "`closed A`" to appear _after_ "`done processing A`" in the immediate sink.

The trouble is determining `N`. It appears to be `highWaterMark + 1` for any value of `highWaterMark` on the producer, provided all subsequent transforms have a `highWaterMark = 1`.

But if subsequent transforms have `highWaterMark > 1` then the number of `pull`s on the source increase from the get-go, throwing off any assumptions about what's going on.

I'd appreciate any pointers or analysis of the spec algorithms that support what's going on in Chrome here.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1155

Received on Tuesday, 3 August 2021 13:06:20 UTC