Re: [whatwg/streams] WritableStream: clear algorithms once they will no longer be called (#940)

domenic commented on this pull request.

This approach will work. I wish it were a bit more elegant, though.

In particular, I'm surprised the controller needs to be told when we're "finished" with it, via [[FinishSteps]](). It's also a bit uncomfortable that with that name, it's only called sometimes.

In the two cases, i.e. steps 9 and 12 of WritableStreamFinishedErroring---is it possible there was an earlier point where the controller could know that its algorithms are clearable?


Or alternately, I think this would work as a different version of WritableStreamFinishedErroring:

- Get rid of [[FinishSteps]]
- Make [[ErrorSteps]] clear the algorithms. (Kinda fits; it already clears the queue.)
- Instead of calling [[ErrorSteps]] at the beginning, call it at the end: i.e., right before the three return points of the algorithm.

WDYT?

>    1. Let _storedError_ be _stream_.[[storedError]].
   1. Repeat for each _writeRequest_ that is an element of _stream_.[[writeRequests]],
     1. <a>Reject</a> _writeRequest_ with _storedError_.
   1. Set _stream_.[[writeRequests]] to an empty List.
   1. if _stream_.[[pendingAbortRequest]] is *undefined*,
+    1. Perform ! _controller_[[FinishSteps]]().

Missing dots here and below.

> @@ -3291,21 +3291,24 @@ nothrow>WritableStreamDealWithRejection ( <var>stream</var>, <var>error</var> )<
   1. Assert: _stream_.[[state]] is `"erroring"`.
   1. Assert: ! WritableStreamHasOperationMarkedInFlight(_stream_) is *false*.
   1. Set _stream_.[[state]] to `"errored"`.
-  1. Perform ! _stream_.[[writableStreamController]].[[ErrorSteps]]().
+  1. Let _controller_ be _stream_.[[writableStreamController]].
+  1. Perform ! _controller_.[[ErrorSteps]]().
   1. Let _storedError_ be _stream_.[[storedError]].
   1. Repeat for each _writeRequest_ that is an element of _stream_.[[writeRequests]],
     1. <a>Reject</a> _writeRequest_ with _storedError_.
   1. Set _stream_.[[writeRequests]] to an empty List.
   1. if _stream_.[[pendingAbortRequest]] is *undefined*,

While here, maybe fix this lowercase "if"

-- 
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/940#pullrequestreview-136374276

Received on Wednesday, 11 July 2018 18:57:31 UTC