Skip to content

refactor!(iroh): adjust Endpoint API to return sensible values when the endpoint as been closed#3924

Merged
dignifiedquire merged 2 commits intomainfrom
ramfox/endpoint-api
Feb 13, 2026
Merged

refactor!(iroh): adjust Endpoint API to return sensible values when the endpoint as been closed#3924
dignifiedquire merged 2 commits intomainfrom
ramfox/endpoint-api

Conversation

@ramfox
Copy link
Copy Markdown
Member

@ramfox ramfox commented Feb 10, 2026

Description

closes #3905

Breaking Changes

  • iroh
    • changed
      • Endpoint::address_lookup() -> Result<&ConcurrentAddressLookup, EndpointError>
      • Endpoint::dns_resolver() -> Result<&DnsResolver, EndpointError>
      • Endpoint::endpoint() -> Result<&quinn::Endpoint, EndpointError>
      • Endpoint::socket() -> Result<Handle, EndpointError>
    • added
      • Endpoint::last_net_report() -> Option<NetReport>
      • EndpointError error enum (with variantEndpointError::Closed)
      • ConnectWithOptsError::EndpointClosed variant

Notes & open questions

Created a new issue, #3925 , for the APIs I still find unsatisfying/unclear.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 10, 2026

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

@ramfox ramfox self-assigned this Feb 10, 2026
@ramfox ramfox added API c-iroh Functionality of the core iroh crate. labels Feb 10, 2026
@ramfox ramfox added this to iroh Feb 10, 2026
@ramfox ramfox added this to the iroh: v0.97 milestone Feb 10, 2026
@github-project-automation github-project-automation bot moved this to 🚑 Needs Triage in iroh Feb 10, 2026
@ramfox ramfox moved this from 🚑 Needs Triage to 👀 In review in iroh Feb 10, 2026
@ramfox ramfox requested review from flub and matheus23 February 10, 2026 17:48
@ramfox ramfox force-pushed the ramfox/endpoint-api branch from f5440f4 to c9aaa59 Compare February 12, 2026 18:15
@ramfox ramfox changed the title refactor(iroh): adjust Endpoint API to return sensible values when the endpoint as been closed refactor!(iroh): adjust Endpoint API to return sensible values when the endpoint as been closed Feb 13, 2026
@dignifiedquire dignifiedquire merged commit 1ed4b72 into main Feb 13, 2026
28 of 30 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in iroh Feb 13, 2026
@dignifiedquire dignifiedquire deleted the ramfox/endpoint-api branch February 13, 2026 08:34
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API c-iroh Functionality of the core iroh crate.

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

api: many Endpoint methods have unexpected behaviours after calling Endpoint::close

3 participants