Skip to content

Add Electrum connection timeout to prevent thread pool exhaustion#75

Open
ben-kaufman wants to merge 1 commit intomainfrom
electrum-connection-fix
Open

Add Electrum connection timeout to prevent thread pool exhaustion#75
ben-kaufman wants to merge 1 commit intomainfrom
electrum-connection-fix

Conversation

@ben-kaufman
Copy link

@ben-kaufman ben-kaufman commented Mar 10, 2026

Summary

Bumps the Synonym Fork to v0.7.0-rc.33 and adds a connection_timeout_secs field to ElectrumSyncConfig (default: 10 s). This bounds Electrum socket operations for both the BDK on-chain and LDK tx-sync clients, preventing Tokio's blocking thread pool from being exhausted by threads stuck on dead sockets under total packet loss (e.g. a captive portal on iOS).

Changes

  • Added connection_timeout_secs: u64 field to ElectrumSyncConfig (default: 10 s). Set to 0 to disable; values above 255 are capped to 255 with a warning logged.

Breaking change: existing struct-literal construction of ElectrumSyncConfig must add the new connection_timeout_secs field or switch to ElectrumSyncConfig { .., ..Default::default() }.

Testing

  • Verify Electrum sync succeeds under normal network conditions.
  • Verify that connecting to a dead/unreachable Electrum server times out within ~10 seconds rather than hanging indefinitely.
  • Verify that setting connection_timeout_secs = 0 disables the timeout.
  • Verify that values above 255 are capped and a warning is logged.
  • Run existing CI test suite across Rust, Kotlin, Swift, and Python bindings.

@ben-kaufman ben-kaufman force-pushed the electrum-connection-fix branch from 034be95 to 831fff1 Compare March 10, 2026 13:34
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Code review

One issue found: missing blank line between test functions (cargo fmt violation).

Comment on lines +3333 to +3334
}
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
Copy link

Choose a reason for hiding this comment

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

Missing blank line between test functions — cargo fmt would insert one here.

Every other top-level item boundary in this file uses a blank line separator (47 occurrences of }\n\n#[ vs. this single }\n#[). cargo fmt enforces blank lines between top-level items.

See CLAUDE.md rule: "ALWAYS run cargo fmt before committing to ensure consistent code formatting".

Suggested change
}
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
}
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant