Re: [whatwg/streams] Treat forAuthorCode as an internal slot of reader object (#984)

MattiasBuelens commented on this pull request.

Right now, I've simply implemented the originally proposed spec change as-is. However, while implementing, I found some issues with how it interacts with async iterators, so I'll need to rework it a bit.

> @@ -648,9 +648,9 @@ option. If <code><a for="underlying source">type</a></code> is set to <code>unde
 
 <emu-alg>
   1. If ! IsReadableStream(*this*) is *false*, throw a *TypeError* exception.
-  1. If _mode_ is *undefined*, return ? AcquireReadableStreamDefaultReader(*this*).
+  1. If _mode_ is *undefined*, return ? Construct(`<a idl>ReadableStreamDefaultReader</a>`, « *this* »).

I'm not really a fan of this. I think I'll change it back to use the abstract operation, and add an optional `forAuthorCode` argument to that operation.

> @@ -617,7 +617,7 @@ option. If <code><a for="underlying source">type</a></code> is set to <code>unde
 
 <emu-alg>
   1. If ! IsReadableStream(*this*) is *false*, throw a *TypeError* exception.
-  1. Let _reader_ be ? AcquireReadableStreamDefaultReader(*this*).
+  1. Let _reader_ be ? Construct(`<a idl>ReadableStreamDefaultReader</a>`, « *this* »).

This is a bit of a problem...
* If we create a reader with `forAuthorCode = false`, then `ReadableStreamCreateReadResult` inside `it.next()` will create an object with `null` prototype, which breaks the contract.
* If we create a reader with `forAuthorCode = false`, then `ReadableStreamDefaultReaderRead` inside `it.next()` will also access `Object.prototype.then` for the internal read result.

I think I'll have to rework this a bit. `ReadableStreamCreateReadResult` should take a `forAuthorCode` argument, rather than a `reader`. In most cases, we'll just pass `reader.[[forAuthorCode]]` as the argument, but in the case of `it.next()` we should explicitly pass `true`, even though `it.[[asyncIteratorReader]].[[forAuthorCode]]` will be `false`.

-- 
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/984#pullrequestreview-201870703

Received on Saturday, 9 February 2019 17:41:31 UTC