Re: [whatwg/streams] Factor out condition to check pending operation (#672)

tyoshino commented on this pull request.



>  
   stream._state = 'errored';
   stream._storedError = e;
 
-  if (stream._pendingAbortRequest === undefined && stream._writer !== undefined) {
-    let readyPromiseIsPending = false;
-    if (oldState === 'writable' &&
-        WritableStreamDefaultControllerGetBackpressure(stream._writableStreamController) === true) {
-      readyPromiseIsPending = true;
+  // TODO(tyoshino): Given that writer.abort() fails immediately when the stream has been errored, shouldn't

> I'm going to assume the question is

Correct, but the situation I'm concerned is when `writer.abort()` is pending due to any in-flight close()/write(). Once they call `controller.error()`, the stream's state transitions to `"errored"`. But until the close()/write() fulfills/rejects the promise it returned and is processed by the stream, we don't reject the `writer.abort()`.

```
const w = writer.write();
const p = writer.abort();  // the abort becomes pending
controller.error();  // the stream becomes errored but abort() is kept pending until sink.write()'s handler is invoked
```

I'm not objecting to this behavior. I just wondered if it's ok that this is inconsistent with `controller.error()` first and then `writer.abort()`, i.e. in reverse order. WritableStreamAbort() returns immediately when the stream is already in the `"errored"` state even before the ongoing close()/write() fulfills/rejects the promise it returned and is processed by the stream.

-- 
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/672#discussion_r105079238

Received on Thursday, 9 March 2017 03:19:05 UTC