refactor!(iroh): adjust Endpoint API to return sensible values when the endpoint as been closed#3924
Merged
dignifiedquire merged 2 commits intomainfrom Feb 13, 2026
Merged
Conversation
|
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3924/docs/iroh/ Last updated: 2026-02-12T18:17:19Z |
flub
approved these changes
Feb 11, 2026
added 2 commits
February 12, 2026 13:08
…the endpoint has been closed
f5440f4 to
c9aaa59
Compare
Endpoint API to return sensible values when the endpoint as been closedEndpoint API to return sensible values when the endpoint as been closed
dignifiedquire
approved these changes
Feb 13, 2026
3 tasks
ramfox
added a commit
that referenced
this pull request
Feb 19, 2026
… but still clean up resources immediately (#3879) ## Description closes #3867 relies on #3924 Alot of finagaling needed to happen to ensure that when the Endpoint is dropped, it's underlying resources are cleaned up ASAP. First, added a custom `Runtime` that wraps spawned tasks in a `CancellationToken`. This allows for both graceful shutdown (which does not use the cancel token, but instead waits for tasks to finish naturally) and ungraceful abort (which uses the cancel token to stop all running tasks) Wrote a new `Handle::abort` method that is sync and does not wait for graceful clean up after cancelling tokens, before aborting any runtime tasks. In order to ensure that the `Endpoint` is only "aborted" on the last clone of the endpoint, `StaticConfig` was moved into the `Handle`, and it was renamed to `EndpointInner` that is now wrapped in an `Arc`. When the `Arc` is finally dropped, the `Drop` impl on `EndpointInner` is called, which calls `Handle::abort`, if the `Endpoint` was not gracefully closed before dropping. This PR also makes sure that we drop any references to address lookup services on close. ## Breaking Changes New behavioral change! Then `Endpoint` does not do ANY best-effort to close connections gracefully before dropping. This makes it even more important to call `Endpoint::close` in all cases. This change (that prevents the underlying `quinn::Endpoint` to do it's best to wait/send close frames before shutting down) has already highlighted in tests how much more brittle it is to drop the endpoint without calling `close` first. ## Change checklist <!-- Remove any that are not relevant. --> - [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. Co-authored-by: “ramfox” <“kasey@n0.computer”> Co-authored-by: Franz Heinzmann <frando@unbiskant.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
closes #3905
Breaking Changes
irohchangedEndpoint::address_lookup() -> Result<&ConcurrentAddressLookup, EndpointError>Endpoint::dns_resolver() -> Result<&DnsResolver, EndpointError>Endpoint::endpoint() -> Result<&quinn::Endpoint, EndpointError>Endpoint::socket() -> Result<Handle, EndpointError>addedEndpoint::last_net_report() -> Option<NetReport>EndpointErrorerror enum (with variantEndpointError::Closed)ConnectWithOptsError::EndpointClosedvariantNotes & open questions
Created a new issue, #3925 , for the APIs I still find unsatisfying/unclear.