[whatwg/streams] Factor out readyPromiseIsPending calculation (#671)

First, this patch factors out readyPromiseIsPending calculation into a function named WritableStreamIsReadyPromisePending().

I also tried to move the readyPromiseIsPending calculation to as earlier position as possible in the caller methods so that we're less likely to call the newly introduced method after changing some of state variables by mistake.

However, while doing so, I found that calling this method in WritableStreamDefaultControllerError() is problematic. Since WritableStreamDefaultControllerError() can be called while the instantiated controller is not yet set to the stream i.e. inside sink.start().

There's similar hack at the bottom of WritableStreamDefaultControllerError() though it seems no longer working (before c6c0a6e68a427be34f0bd1166c991f811379c32a, it was placed in WritableStreamError() and retrieving the controller from the stream instance, and therefore had the same issue). Rather than getting bothered by these corner case handling now and in the future, this patch lets the stream finish instantiation of a controller and then invoke sink.start().
You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/streams/pull/671

-- Commit Summary --

  * Factor out readyPromiseIsPending calculation

-- File Changes --

    M index.bs (68)
    M reference-implementation/lib/writable-stream.js (88)

-- Patch Links --

https://github.com/whatwg/streams/pull/671.patch
https://github.com/whatwg/streams/pull/671.diff

-- 
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/671

Received on Wednesday, 25 January 2017 09:48:55 UTC