stream: add diagnostics_channel event for completion
This adds a stream.web.done
diagnostics channel to Web Streams. with the intention of having a straightforward way to detect when a ReadableStream
has been read to completion, without triggering the reading of the stream.
This is useful for instrumentation tools trying to measure the length of a request/response cycle triggered by a fetch()
.
Why draft?
Right now I'm only testing directly calling read()
and async iterators. pipeThrough()
, pipeTo()
, and cancellation all need to be tested (and perhaps implemented).
Also, the naming is certainly open for suggestions. I based the name of the channel on the only other prior art in Node.js core.
Finally, I had a weird thing happen with mksnapshot
, so I'm wondering if anyone knows how to better work around that. See the inline comment below.
All that being said, I thought it was worth opening it now anyway, to make sure the approach is sound and agreeable.