- From: Adam Rice <notifications@github.com>
- Date: Thu, 06 Apr 2017 04:45:42 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/issues/727@github.com>
This is an abridged version of the 'Piping from an errored readable stream to a closed writable stream' test: ```javascript promise_test(t => { const rs = new ReadableStream({ start(c) { c.error(error1); } }); const ws = new WritableStream(); const writer = ws.getWriter(); const closePromise = writer.close(); writer.releaseLock(); return Promise.all([ promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo should reject'), promise_rejects(t, new TypeError(), closePromise, 'close() should reject') ]); }, 'Piping from an errored readable stream to a closing writable stream'); ``` The expectations have been changed to match what Blink's implementation does. In the reference implementation `closePromise` is fulfilled. This is because Blink is calling WritableStreamAbort() synchronously and the reference implementation is calling it asynchronously. I originally thought this was a bug in Blink's implementation and filed https://bugs.chromium.org/p/chromium/issues/detail?id=684543, but now I think the reference implementation doesn't match the standard. The standard says about pipeTo(): > - **Errors must be propagated forward:** if **this**.[[state]] is or becomes `"errored"`, then > - If _preventAbort_ is **false**, shutdown with an action of ! WritableStreamAbort(_dest_, **this**.[[storedError]]) and with **this**.[[storedError]]. In this case, [[state]] **is** `"errored"`, so we should _shutdown with an action_. _Shutdown with an action_ says: > 1. If _dest_.[[state]] is "writable" and ! WritableStreamCloseQueuedOrInFlight(_dest_) is **false**, > a. If any chunks have been read but not yet written, write them to dest. > b. Wait until every chunk that has been read has been written (i.e. the corresponding promises have settled). > 2. If _shuttingDown_ is true, abort these substeps. > 3. Set _shuttingDown_ to true. > 4. Let _p_ be the result of performing _action_. In this case WritableStreamCloseQueuedOrInFlight(_dest_) is **true**, so we should perform _action_ without waiting. -- 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/727
Received on Thursday, 6 April 2017 11:46:21 UTC