Re: [whatwg/streams] Release reader immediately when shutting down a pipe (PR #1208)

@MattiasBuelens commented on this pull request.

I've updated the reference implementation to fix the issue from https://github.com/whatwg/streams/issues/1207#issuecomment-1017947644. I still need to update the spec text, although this might be tricky because the `pipeTo()` specification is a bit vague on *how* to implement the "if dest becomes errored" check. 😕

Also, is it okay to piggyback this fix onto this PR, or would you prefer I move it to a separate one? (The new fix does *depend* on the initial fix though, we can't land it entirely separately.)

> @@ -228,7 +235,8 @@ function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventC
     });
 
     // Errors must be propagated backward
-    isOrBecomesErrored(dest, writer._closedPromise, storedError => {
+    WritableStreamDefaultWriterIsOrBecomesErrored(writer, () => {

This new helper allows attaching a *synchronous* callback for when *dest* becomes `"erroring"` or `"errored"`, following the discussion in https://github.com/whatwg/streams/issues/1207#issuecomment-1017947644. I added a test for this in https://github.com/web-platform-tests/wpt/commit/1646d657bf258f850afb5f22860ec02dccbc6b7a.


> -      is or becomes "`errored`", then
+      is or becomes "`erroring`" or "`errored`", then

I don't think it's useful to keep the pipe going when *dest* has already become `"erroring"`? Any new writes will just error immediately, as per [step 9 of WritableStreamDefaultWriterWrite](https://streams.spec.whatwg.org/commit-snapshots/908ceddfb813ec0d9c727393edfb13d810e694f1/#writable-stream-default-writer-write).

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1208#pullrequestreview-858876713

You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/pull/1208/review/858876713@github.com>

Received on Thursday, 20 January 2022 22:43:58 UTC