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

tyoshino commented on this pull request.



> @@ -760,6 +782,7 @@ function WritableStreamDefaultControllerGetChunkSize(controller, chunk) {
   try {
     return strategySize(chunk);
   } catch (chunkSizeE) {
+    // TODO: Should we notify the sink of this error?

I felt like this has been removed by you sometime before, but not fully sure and so I kept this while merging and forgot to mention this in the PTAL comments. Thanks for confirming. Removed.

> +
+  if (stream._pendingAbortRequest === undefined) {
+    stream._state = 'errored';
+    stream._storedError = reason;
+
+    const writer = stream._writer;
+    if (writer !== undefined) {
+      if (WritableStreamCloseInQueueOrInFlight(stream) === false && stream._backpressure === true) {
+        defaultWriterReadyPromiseReject(writer, reason);
+      } else {
+        defaultWriterReadyPromiseResetToRejected(writer, reason);
+      }
+      writer._readyPromise.catch(() => {});
+    }
+
+    WritableStreamRejectPromisesInReactionToError(stream, reason);
 
     return;
   }
 
   stream._state = 'errored';

Trying to factor out common logic resulted in having code that is hard to compare with the others (WritableStreamFinish.* methods) to make sure what's needed in each of them are really included, given that several conditions are entangled.

So, I've flattened all the methods and sought better way. But yes, here it looks okay to dedupe these. Done.

-- 
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_r104659210

Received on Tuesday, 7 March 2017 13:03:42 UTC