Re: [whatwg/streams] [WritableStream] Shouldn't the state after writer.abort() be closed? (#464)

> At some point, IIRC, we discussed some redesign of pipeTo() interface. After introducing locking mechanism to both, we need to extend pipeTo() to give us some controller (I'm not catching up with progress on cancellable promise. It could be to some extent covered by it).

Right. FYI this will probably be covered by passing a cancel token as an option to pipeTo. So

```js
const { token, cancel } = CancelToken.source();
rs.pipeTo(ws, { cancelToken: token });

cancelButton.onclick = cancel;
```

This would cancel `rs`, clearly, but I am not sure whether it should abort or close `ws`. Hmm. I guess that could even be an option that you pass to `cancel()`.

> Hmm, yeah. I remembered that we agreed on that abort() should play the role of having a writable stream pretend to be errored by itself for the externally-provided reason. But I thought that it was backed by the demand to implement the way to abort pipeTo() operation and propagating error to both direction. It's gone.

I don't really remember that. To me the important thing is that if you do something like

```js
rs.pipeThrough(transform).pipeTo(ws);
```

and then writing to `ws` errors (I/O error etc.), this propagates backward. At the very least that means `rs` must be canceled. But I think it should also mean that `transform.writable` becomes errored and `transform.readable` becomes closed?

The way I originally envisioned this working is that pipeTo would see `ws` become errored, and use that to cancel `transform.readable`, and then the transform stream machinery would see the premature cancel and react to it to make `transform.writable` errored, which would mean that the piping of `rs` to `transform.writable` sees its destination error and cancels `rs`. This seems nice to me.

But maybe it is not the optimal design and I should be more creative thinking of ways for this to work. I do not think it is inherently important that `transform.writable` become errored and that `transform.readable` become closed. That was just a nice way to accomplish the important goal that `rs` become canceled.

---
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/464#issuecomment-223394904

Received on Thursday, 2 June 2016 19:22:28 UTC