Re: [whatwg/streams] Unified error handling for WritableStream (#721)

ricea commented on this pull request.



> -  1. Perform ! WritableStreamRejectAbortRequestIfPending(_stream_).
-  1. Perform ! WritableStreamRejectPromisesInReactionToError(_stream_).
+  1. Assert: _stream_.[[storedError]] is *undefined*.
+  1. Assert: _stream_.[[state]] is `"writable"`.
+  1. Let _controller_ be _stream_.[[writableStreamController]].
+  1. Assert: _controller_ is not *undefined*.
+  1. Set _stream_.[[state]] to `"erroring"`.
+  1. Set _stream_.[[storedError]] to _reason_.
+  1. Let _writer_ be _stream_.[[writer]].
+  1. If _writer_ is not *undefined*, perform !
+     WritableStreamDefaultWriterEnsureReadyPromiseRejected(_writer_, _reason_).
+  1. If ! WritableStreamHasOperationMarkedInFlight(_stream_) is *false* and _controller_.[[started]] is *true*, perform
+     ! WritableStreamFinishError(_stream_).
+</emu-alg>
+
+<h4 id="writable-stream-finish-error" aoid="WritableStreamFinishError" nothrow>WritableStreamFinishError

Makes sense. One that that bugs me is that StartErroring conditionally calls FinishErroring directly. This avoids duplicating the condition in 2 of the callers, and the condition is always true in WritableStreamDealWithRejection so it seems like the right thing, but I still find it confusing.

-- 
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/721#discussion_r109873583

Received on Wednesday, 5 April 2017 09:50:56 UTC