Re: [whatwg/streams] Resolving promises with byte sequences results in UB (Issue #1178)

I assume we cannot implement [convert to an ECMAScript value](https://webidl.spec.whatwg.org/#dfn-convert-idl-to-ecmascript-value) for [byte sequence](https://infra.spec.whatwg.org/#byte-sequence), since it's not an IDL type? So [read all bytes](https://streams.spec.whatwg.org/commit-snapshots/ea03a24deb75928bfa7c285611d4ac2daf332957/#readablestreamdefaultreader-read-all-bytes) must return a `Promise` for a `Uint8Array` instead, and we have to first convert the byte sequence to a `Uint8Array`. We must also change step 4 of [consume body](https://fetch.spec.whatwg.org/commit-snapshots/9bfe9e790d10a17c3208aa47beb073ffe27acec8/#concept-body-consume-body) to convert the `Uint8Array` back into a byte sequence before passing it to [package data](https://fetch.spec.whatwg.org/commit-snapshots/9bfe9e790d10a17c3208aa47beb073ffe27acec8/#concept-body-package-data).

Alternatively, we can make [read all bytes](https://streams.spec.whatwg.org/commit-snapshots/ea03a24deb75928bfa7c285611d4ac2daf332957/#readablestreamdefaultreader-read-all-bytes) *not* return a `Promise`, and instead take `successSteps` and `errorSteps` arguments. Then we aren't limited by Web IDL conversions, and we can pass a byte sequence directly to `successSteps`.

-- 
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/1178#issuecomment-947478854

Received on Wednesday, 20 October 2021 09:14:14 UTC