- From: Debadree Chatterjee <notifications@github.com>
- Date: Mon, 18 Sep 2023 12:29:27 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/issues/1294@github.com>
On reading the spec for https://streams.spec.whatwg.org/#readable-stream-close we see it asks to perform close steps in case of [ReadableStreamDefaultReader](https://streams.spec.whatwg.org/#readablestreamdefaultreader) but what about the case when its a byob reader? this was first noted when trying to implement https://github.com/nodejs/node/issues/47993 a simple example: ```mjs async function test() { const toPull = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']; const st = new ReadableStream({ type: 'bytes', start(controller) {}, pull(controller) { const chunk = toPull.shift(); if (chunk === undefined) { controller.close(); return; } controller.enqueue(new TextEncoder().encode(chunk)); }, }); const reader = st.getReader({ mode: 'byob' }); const decoder = new TextDecoder(); console.log('start'); let result; do { result = await reader.read(new Uint8Array(100)); if (result.value !== undefined) console.log(decoder.decode(result.value)); } while (!result.done); console.log('end'); } await test(); ``` would expect both start and end to be printed to console but both node and chrome give the following output: ```console start a b c d e f g h i j ``` this in contrast to `ReadableStreamError()` which branches for both byob and normal. Is this behaviour intended? i am unable to understand unfortunately 😅 any help in understanding would be greatly appreciated! Thank You! -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/issues/1294 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/streams/issues/1294@github.com>
Received on Monday, 18 September 2023 19:29:34 UTC