Re: [whatwg/streams] Pipe completes before all writes are finished with preventClose = true (#882)

@ricea Yes, the test passes! 🎉

I only had to update the test slightly because of some API changes:
<details>
<summary>Test</summary>

```js
promise_test(t => {

  const rs = recordingReadableStream();

  let resolveWriteCalled;
  const writeCalledPromise = new Promise(resolve => {
    resolveWriteCalled = resolve;
  });

  let resolveWritePromise;
  const ws = recordingWritableStream({
    write() {
      resolveWriteCalled();

      return new Promise(resolve => {
        resolveWritePromise = resolve;
      });
    }
  }, new CountQueuingStrategy({ highWaterMark: 2 })); // CHANGED: strategy constructor takes an object

  let pipeComplete = false;
  const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws)).then(() => {
    pipeComplete = true;
  });

  rs.controller.enqueue('a');
  rs.controller.enqueue('b');

  return writeCalledPromise.then(() => flushAsyncEvents()).then(() => {
    assert_array_equals(ws.events, ['write', 'a'], 'abort should not be called before the first write completes');
    assert_false(pipeComplete, 'the pipe should not complete while the first write is pending');

    rs.controller.error(error1);
    resolveWritePromise();
    return flushAsyncEvents();
  }).then(() => {
    assert_array_equals(ws.events, ['write', 'a', 'write', 'b'],
      'abort should not be called before the second write completes');
    assert_false(pipeComplete, 'the pipe should not complete while the second write is pending');

    resolveWritePromise();
    return pipePromise;
  }).then(() => {
    assert_array_equals(ws.events, ['write', 'a', 'write', 'b', 'abort', error1], 'sink abort should be called'); // CHANGED: abort reason is also recorded
  });

}, 'Errors must be propagated forward: abort should not happen until all queued writes complete');
```
</details>

-- 
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/issues/882#issuecomment-366084939

Received on Thursday, 15 February 2018 22:36:16 UTC