Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abort after close #165

Closed
martinthomson opened this issue Nov 11, 2020 · 5 comments
Closed

Abort after close #165

martinthomson opened this issue Nov 11, 2020 · 5 comments

Comments

@martinthomson
Copy link
Member

In #137, @ricea points out that there is a capability of QUIC that streams can't natively support. That is, it is possible to abort the send side of a stream after closing it. This is useful in cases where the contents of the stream are time-sensitive, such that retransmitting lost packets isn't worthwhile. This is one of the ways in which QUIC can emulate some of the "partial reliability" functions of SCTP/WebRTC data channels.

However, if the WHATWG streams API can't support this, that means supporting an abortWriting function that operates very much like writer.abort() with this one extra quirk. That is horrible. My preference would be to have WHATWG recognize that close is non-atomic and that aborting a closed stream is legitimate, but if that doesn't work out, then I would argue for not retaining the capability.

@ricea
Copy link
Contributor

ricea commented Nov 11, 2020

The current semantics of WHATWG streams have been shipping for a long time and we can't change them without breaking existing websites. WebTransport is the only use case I've encountered where abort after close is meaningful.

In simple cases you can achieve similar functionality by waiting for the final write() on the stream to complete and then calling abort(), but if someone absolutely needs to send a STREAM_FINAL before the RESET_STREAM then abortWriting() would be the only way to accomplish that.

As a result, I have a mild preference for retaining abortWriting().

@vasilvv
Copy link
Contributor

vasilvv commented Nov 11, 2020

For reference, when we were originally designing the API, we wanted to include a feature that allows you to set a TTL on streams (that is to say, a time after which the stream is automatically reset) as we envisioned that this would be commonly used in livestreaming/real-time cases. We decided against that, because doing this is currently as easy as:

setTimeout(() => { stream.abortWriting(); }, 1000 /* TTL in ms */);

@jan-ivar
Copy link
Member

As a result, I have a mild preference for retaining abortWriting().

@ricea the WG was wondering what the reason for the mild preference is? Is it so that JS doesn't have to hold a reference to the writer?

@ricea
Copy link
Contributor

ricea commented Jan 20, 2021

@ricea the WG was wondering what the reason for the mild preference is? Is it so that JS doesn't have to hold a reference to the writer?

No, it's purely so that you can reset a closed stream. It is my understanding that this is necessary to implement unreliable streams without needing to add an in-band end marker at the application layer. I am assuming this is useful for sending small unreliable messages without needing to worry about the datagram size limit.

@wilaw
Copy link
Contributor

wilaw commented Jun 2, 2021

Moving discussion to #260

@wilaw wilaw closed this as completed Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants