- From: James M Snell <notifications@github.com>
- Date: Mon, 26 Feb 2024 18:23:22 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/issues/1307@github.com>
### What is the issue with the Streams Standard? The Explicit Resource Management proposal is moving forward in TC-39 and implementers are making progress. One thing I'm not sure has been discussed here is how, if at all, the streams spec should implement ERM. Let's consider `ReadableStream` first. Let's assume that it is decided that `ReadableStream` should be disposable... Would it support `Symbol.dispose` (sync disposal) AND `Symbol.asyncDispose` or just async dispose? Let's use an example ```js const rs = new ReadableStream({ async cancel() { // just fake some async activity await scheduler.wait(1000); } }); { using stream = rs } ``` Would we expect that the sync disposer triggers the async cancel algorithm if the `ReadableStream` is still open and readable? Does a sync disposer even make sense in this case or should it always be `await using`? Does it even make sense to support disposing of the `ReadableStream` like this? If it is, would it just simply be the equivalent of calling `cancel()` with no reason? Let's consider a reader: ```js { using reader = rs.getReader(); } ``` When the block exits, do we release the lock on the stream or do we cancel the stream via the reader? Releasing the lock is synchronous (suggesting that the sync `Symbol.dispose` would be sufficient) but canceling is async (suggesting that we would need `Symbol.asyncDispose`). Let's consider a more complex case (this part may be more appropriate for the fetch repo so if we need to discuss it there, let me know)... Let's assume that the stream is attached to a disposable type, and let's assume that `Response` is defined as disposable... what should we expect would happen to the stream in the following case: ```js let stream; { using resp = await fetch('http://example.com'); stream = resp.body; } // Is the stream still readable here? Or was it disposed of? const reader = stream.getReader(); // ?? ``` The same basic questions apply to `WritableStream`, of course ```js const ws = new WritableStream({ async abort() { await scheduler.wait(1000); } }); let writer; { // is sync dispose ok here? will it trigger the abort alg? using stream = ws; writer = stream.getWriter(); } // is writer still usable? ``` -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/issues/1307 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/streams/issues/1307@github.com>
Received on Tuesday, 27 February 2024 02:23:26 UTC