Skip to content

feat: add esplora client timeout option - #1119

Open
Arowolokehinde wants to merge 1 commit into
bitcoindevkit:masterfrom
Arowolokehinde:feat-esplora-client-timeout
Open

Arowolokehinde wants to merge 1 commit into
bitcoindevkit:masterfrom
Arowolokehinde:feat-esplora-client-timeout

Conversation

@Arowolokehinde

Copy link
Copy Markdown

Description

Closes #1109

EsploraClient::new had no way to set a request timeout: proxy was the
only setting it applied to esplora_client::Builder, leaving the
builder's timeout at None. A server that accepts a connection then stops
responding could block the calling thread indefinitely.

This adds an optional timeout (seconds), mirroring ElectrumClient::new. It
defaults to None, so callers opt in.

Notes to the reviewers

  • Defaults to None as suggested, so nothing changes for existing callers.
    Added a docstring note for the hang risk when it's unset.
  • Option<u8> seconds matches ElectrumClient.
  • Verified against a local stub server that accepts a connection and never
    replies. With timeout unset the call never returned; with timeout = 3 it
    raised Minreq("the timeout of the request was reached") after 3.01s —
    catchable rather than a hang.
  • No test added - this needs a server that accepts and then stalls.
  • I don't have permissions to add labels - could someone apply
    changelog: added?

Documentation

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing
  • I've added exactly one changelog:* label
  • I've linked the relevant upstream docs or specs above

New Features:

  • I've added docs for the new feature

@j-kon j-kon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 853a5ba

@Arowolokehinde

Copy link
Copy Markdown
Author

i would like to hear what you think about this pr @reez whenever you are chanced to

@thunderbiscuit thunderbiscuit left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should stick to what upstream exposes. I agree it's not optimal that our Electrum and Esplora clients use different parameters but I think it's easier to stick with what they have and PR changes we want upstream.

In this case, the newest Esplora client (0.13.0) switches to bitreq and this argument becomes a Duration, same as with the Electrum client. We can fix this up and use the u8 at that point since that's how we do it on Electrum.

Otherwise once that little fix is done and the PR is rebased I think this looks ready to go.

Comment thread bdk-ffi/src/esplora.rs Outdated
/// Optional: Set the timeout (in seconds) of the builder. When unset, no timeout is
/// configured and a request can block indefinitely if the server stops responding.
#[uniffi::constructor(default(proxy = None, timeout = None))]
pub fn new(url: String, proxy: Option<String>, timeout: Option<u8>) -> Self {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's mirror the upstream type here and expose a u64 instead of a u8.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining the reasoning, and i agree on mirroring upstream, so I just exposed it as u64.

Comment thread bdk-ffi/src/esplora.rs
if let Some(proxy) = proxy {
builder = builder.proxy(proxy.as_str());
}
if let Some(timeout) = timeout {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given my comment above, the .into() here will become redundant.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I just removed .into() since the parameter is now u64.

@thunderbiscuit thunderbiscuit added this to the 3.2.0 milestone Oct 9, 2026
EsploraClient::new had no way to set a request timeout: it only
forwarded proxy to esplora_client::Builder, leaving the builder's
timeout at None. A server that accepts a connection then stops
responding could block the calling thread indefinitely.

Add an optional timeout, as Option<u64> seconds to match
esplora_client::Builder::timeout. It defaults to None so callers opt in
and existing behavior is unchanged, and the docs note that a request can
block indefinitely when it is unset.
@Arowolokehinde
Arowolokehinde force-pushed the feat-esplora-client-timeout branch from 853a5ba to 091c7b2 Compare October 9, 2026 21:09
@Arowolokehinde
Arowolokehinde requested a review from a team as a code owner October 9, 2026 21:09

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Add a configurable request timeout to EsploraClient

3 participants