Re: [whatwg/streams] Aborting a stream should wait for pending writes (#619)

ricea commented on this pull request.



> @@ -20,6 +20,12 @@ class WritableStream {
     // producer without waiting for the queued writes to finish.
     this._writeRequests = [];
 
+    // Write requests are removed from _writeRequests when write() is called on the underlying sink. This prevents
+    // them from being erroneously rejected on error. If a write() call is pending, the request is stored here.
+    this._pendingWriteRequest = undefined;
+
+    this._pendingCloseRequest = undefined;

Consider

```javascript
const promise1 = writer.close();
const promise2 = writer.closed;
writer.releaseLock(); // [1]
```

`promise2` becomes rejected at [1], but `promise1` may not resolve until later.

Except... https://github.com/whatwg/streams/blob/master/reference-implementation/lib/writable-stream.js#L169 thinks you shouldn't be able to do this. If that line is correct and the implementation of `releaseLock()` is wrong, then maybe the `close()` and `.closed` promises can have a shared fate after all.

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

Received on Thursday, 24 November 2016 12:22:26 UTC