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

API for awaiting for stream reset on the reader #1870

Closed
MOZGIII opened this issue May 19, 2024 · 5 comments · Fixed by #1873
Closed

API for awaiting for stream reset on the reader #1870

MOZGIII opened this issue May 19, 2024 · 5 comments · Fixed by #1873

Comments

@MOZGIII
Copy link

MOZGIII commented May 19, 2024

Would be great to have an API that would allow waiting for a stream reset from the reader end. This is something that WebTransport API for the Web has, and it would be nice for supporting cross-platform interfaces for WebTransport (like xwt).

WebTransport is relevant in the context of QUIC and quinn because WebTransport is a protocol that builds on top of HTTP3, which builds on top of QUIC.

Concretely, I need this because I am having issues properly modeling interfaces at MOZGIII/xwt#152.

@Ralith
Copy link
Collaborator

Ralith commented May 19, 2024

What's the difference between waiting for a reset and reading? Can you link the spec for the WebTransport API you're referring to?

@MOZGIII
Copy link
Author

MOZGIII commented May 19, 2024

Based on this: https://w3c.github.io/webtransport/

There is a WebTransport object. It can create streams, which are represented via

There are no relevant methods in the subclasses, so we can focus on the base classes: WritableStream and ReadableStream.

ReadableStream allows getting a ReadableStreamReader, which is either a ReadableStreamDefaultReader or ReadableStreamBYOBReader - but both include ReadableStreamGenericReader .

The ReadableStreamGenericReader has a readonly attribute Promise<undefined> closed; - which in turns allows awaiting for the stream to close without actually reading it (as I understand it). Upon getting an RESET, the promise returned by closed would reject with a WebTransportError, which would contain the error code.

This is what I find missing in the quinn API.


Maybe I am misinterpreting my findings in the Web API, but then I need some tips on the topic of implementing this - but it seems like the Web API for WebTransport does have an API that can't be (simply) built on top of quinn.

@Ralith
Copy link
Collaborator

Ralith commented May 19, 2024

I find the web spec difficult to read (lots of circular definitions that don't actually specify anything useful), but the general idea you describe seems to make sense, and I don't oppose having such an API, even though its use may be niche. Our existing SendStream::stopped is similar.

@MOZGIII
Copy link
Author

MOZGIII commented May 19, 2024

Yep, SendStream::stopped covers it for the send streams, it is only the reading streams that don't have a matching counter part for that.

web spec difficult

Yeah, it is. I am not specializing on dealing with w3c stuff, had to dig through this just for the cross platform WebTransport, and it was veery tricky to spot this API even existing.

@Ralith
Copy link
Collaborator

Ralith commented May 19, 2024

Let me know if #1873 suits your requirements. Particular points of interest are &mut self and the non-idempotent behavior.

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

Successfully merging a pull request may close this issue.

2 participants