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

fix(iroh): remove quinn::Endpoint::wait_idle from iroh::Endpoint::close process #3165

Merged
merged 2 commits into from
Feb 4, 2025

Conversation

ramfox
Copy link
Contributor

@ramfox ramfox commented Feb 3, 2025

Description

quinn::Endpoint::wait_idle adds a minimum 3 second closing time to iroh::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

  • Self-review.
  • Documentation updates following the style guide, if relevant.

Copy link

github-actions bot commented Feb 3, 2025

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

Copy link

github-actions bot commented Feb 3, 2025

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: 0fb79a3

@ramfox ramfox added this pull request to the merge queue Feb 4, 2025
Merged via the queue into main with commit a1d21c6 Feb 4, 2025
27 checks passed
@ramfox ramfox deleted the ramfox/remove-wait-idle branch February 4, 2025 00:28
///
/// 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.
Copy link
Contributor

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?

Copy link
Member

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

matheus23 added a commit that referenced this pull request Feb 5, 2025
matheus23 added a commit that referenced this pull request Feb 17, 2025
github-merge-queue bot pushed a commit that referenced this pull request Feb 18, 2025
## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants