-
Notifications
You must be signed in to change notification settings - Fork 222
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
fix(iroh): remove quinn::Endpoint::wait_idle
from iroh::Endpoint::close
process
#3165
Conversation
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3165/docs/iroh/ Last updated: 2025-02-03T23:09:34Z |
/// | ||
/// 1) The **sender** sends the last data. It then calls [`Connection::closed`]. This will wait until it receives a CONNECTION_CLOSE frame from the other side. | ||
/// 2) The **receiver** receives the last data. It then calls [`Connection::close`] and provides an error_code and/or reason. | ||
/// 3) The **sender** checks that the error_code is the expected error code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This provides no guidance how the receiver of the last data ensures that the close is sent and delivered. Which possibly is no longer possible right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - this seems impossible at the moment, see also this failing test case that's fixed by reverting this PR: 82334ca
## Description This adds a test case that checks that we can call `Connection::close` and actually receive the close code on the other side, indicating we've gracefully closed the connection. Even though in the test we call `Endpoint::close` and wait for that, with current iroh 0.32, we don't receive the close frame. The only way I can see to make it work with iroh's 0.32 API, is to choose some time to sleep before calling `Endpoint::close`. I've also attached a revert of #3165 which fixes the test, as that makes `Endpoint::close` wait for the close frames to be acknowledged again (by calling `quinn::Endpoint::wait_idle`). ## Notes & open questions There might be other ways to fix this, I welcome feedback on that. I do believe this is the right way to fix it, though. Given that the `Endpoint::wait_idle` call has been introduced and removed *twice* already, we should finally make a choice on whether it belongs in there or not, and then add sufficient code comments to make sure whoever looks at it next is fully informed. ## Change checklist - [x] Self-review. - [x] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [x] Tests if relevant. - [x] All breaking changes documented.
Description
quinn::Endpoint::wait_idle
adds a minimum 3 second closing time toiroh::Endpoint::close
if you have any connections that have not closed gracefully.While we want users to close connections gracefully, we should also not be forcing users to wait 3 seconds to close the
iroh::Endpoint
if a connection has "gone wrong" if they don't want to.So instead, we are taking out
quinn::Endpoint::wait_idle
and adding more context for how to close a connection gracefully.Notes & open questions
Before 1.0 we will be re-visiting closing to make sure the APIs make sense.
Change checklist