- From: Mattias Buelens <notifications@github.com>
- Date: Sat, 09 Oct 2021 12:16:41 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Saturday, 9 October 2021 19:16:53 UTC
@MattiasBuelens commented on this pull request. > controller.byobRequest.respond(bytesRead); } else { const buffer = new ArrayBuffer(DEFAULT_CHUNK_SIZE); bytesRead = socket.readInto(buffer, 0, DEFAULT_CHUNK_SIZE); - controller.enqueue(new Uint8Array(buffer, 0, bytesRead)); `enqueue()` throws if `chunk.byteLength === 0` ([see step 1](https://streams.spec.whatwg.org/commit-snapshots/8bbfbf83ad06a8b9224bbe1cfbcbbbdbdd827a19/#rbs-controller-enqueue)), so we must check `bytesRead` first. > @@ -7234,15 +7234,21 @@ function makeUDPSocketStream(host, port) { if (controller.byobRequest) { const v = controller.byobRequest.view; bytesRead = socket.readInto(v.buffer, v.byteOffset, v.byteLength); + if (bytesRead === 0) { + controller.close(); If `bytesRead === 0`, then we must close the stream first, otherwise `respond(bytesRead)` will throw ([see step 5.2](https://streams.spec.whatwg.org/commit-snapshots/8bbfbf83ad06a8b9224bbe1cfbcbbbdbdd827a19/#readable-byte-stream-controller-respond)). -- 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/pull/1173#pullrequestreview-775602177
Received on Saturday, 9 October 2021 19:16:53 UTC