Wrap endpoint.Online and friends with something that times out? #36

Open
opened 2026-11-13 17:33:27 +00:00 by decentral1se · 4 comments
Owner

Any API proposals in this regard @cblgh?

// NOTE (2026-10-22): pretty sure program execution stops here if you can't
// get a connection to a relay (e.g. if you are rate-limited for too many tries)
e.Online()

I guess I should maybe check the Rust source first because this function returns nothing? There are a couple of these functions, so it might be good to develop a convention of <...>WithTimeout or something so I can wrap all the rest of them with a generic time out implementation?

I noted this in https://git.coopcloud.tech/decentral1se/iroh-go#known-issues

Some interfaces such as conn.Closed() and endpoint.Online() should ideally expose a send/receive channel interface but instead work as a blocking call (where .await() is called internally).

Do we need to propose a default timeout internally also? 10 seconds?

Any API proposals in this regard @cblgh? https://git.coopcloud.tech/cblgh/iroh-tracker/src/commit/51527839540f2d8e2726d744cb85fa4f781f0cf5/itcp/dialer.go#L157-L159 I guess I should maybe check the Rust source first because this function returns nothing? There are a couple of these functions, so it might be good to develop a convention of `<...>WithTimeout` or something so I can wrap all the rest of them with a generic time out implementation? I noted this in https://git.coopcloud.tech/decentral1se/iroh-go#known-issues > Some interfaces such as `conn.Closed()` and `endpoint.Online()` should ideally expose a send/receive channel interface but instead work as a blocking call (where `.await()` is called internally). Do we need to propose a default timeout internally also? 10 seconds?
Collaborator

Here's .online from the JS bindings of iroh-ffi

    /// Resolves once the endpoint has a usable home relay.
    #[napi]
    pub async fn online(&self) {
        self.inner.online().await;
     }

As for what to do, I don't really know. I think setting defaults for something like this has consequences if we choose the wrong value.

Your hunch to go for WithTimeout seems like it could be a good approach? All the Options right now are EndpointBuilder-focused though, so might make the endpoint/ internals messier ^^

From my pov, I feel like I would want something specific like WithWaitOnlineTimeout(t time.Time) and WithWaitOnline(), the latter being equivalent to calling endpoint.Online (i.e. potentially waiting forever) inside iroh.Endpoint.New() before returning the endpoint we built.

Here's `.online` from the [JS bindings of iroh-ffi](https://github.com/n0-computer/iroh-ffi/blob/main/iroh-js/src/endpoint.rs#L429-L434) ```rust /// Resolves once the endpoint has a usable home relay. #[napi] pub async fn online(&self) { self.inner.online().await; } ``` --- As for what to do, I don't really know. I think setting defaults for something like this has consequences if we choose the wrong value. Your hunch to go for `WithTimeout` seems like it could be a good approach? All the `Options` right now are `EndpointBuilder`-focused though, so might make the `endpoint/` internals messier ^^ From my pov, I feel like I would want something specific like `WithWaitOnlineTimeout(t time.Time)` and `WithWaitOnline()`, the latter being equivalent to calling `endpoint.Online` (i.e. potentially waiting forever) inside `iroh.Endpoint.New()` before returning the endpoint we built.
Collaborator

@decentral1se There are a couple of these functions

Which other ones have you come across? I've only ran into .Online acting up and don't know about any others

> @decentral1se There are a couple of these functions Which other ones have you come across? I've only ran into `.Online` acting up and don't know about any others
Author
Owner

Oh indeed, I was mistaken, the other calls I suspected do actually return something. That's good! This is much less impactful than I first thought then. I guess we can just leave it here until it becomes more annoying. I like the customisable API proposal.

Oh indeed, I was mistaken, the other calls I suspected do actually return something. That's good! This is much less impactful than I first thought then. I guess we can just leave it here until it becomes more annoying. I like the customisable API proposal.
Author
Owner
Related https://codeberg.org/cblgh/jasmine-teehaus/issues/1#issuecomment-27965245
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: decentral1se/iroh-go#36