backend: avoid panic on electrum timeout#3902
Merged
strmci merged 1 commit intoBitBoxSwiss:masterfrom Mar 6, 2026
Merged
Conversation
benma
requested changes
Mar 3, 2026
Comment on lines
77
to
109
| func (f *failoverClient) HeadersSubscribe(result func(header *types.Header)) { | ||
| failover.Subscribe( | ||
| failover.SubscribeAlwaysFailover( | ||
| f.failover, | ||
| func(c *client, result func(*types.Header, error)) { | ||
| c.HeadersSubscribe(func(header *types.Header, err error) { | ||
| result(header, err) | ||
| }) | ||
| c.HeadersSubscribe(result) | ||
| }, | ||
| func(header *types.Header, err error) { | ||
| if err != nil { | ||
| // Can only happen if the failover client is closed. | ||
| return | ||
| } | ||
| result(header) | ||
| }) | ||
| } | ||
|
|
||
| func (f *failoverClient) RelayFee() (btcutil.Amount, error) { | ||
| return failover.Call(f.failover, func(c *client) (btcutil.Amount, error) { | ||
| return c.RelayFee() | ||
| }) | ||
| } | ||
|
|
||
| func (f *failoverClient) ScriptHashGetHistory(scriptHashHex blockchain.ScriptHashHex) (blockchain.TxHistory, error) { | ||
| return failover.Call(f.failover, func(c *client) (blockchain.TxHistory, error) { | ||
| return c.ScriptHashGetHistory(scriptHashHex) | ||
| }) | ||
| } | ||
|
|
||
| func (f *failoverClient) ScriptHashSubscribe( | ||
| setupAndTeardown func() func(), | ||
| scriptHashHex blockchain.ScriptHashHex, | ||
| result func(status string)) { | ||
| failover.Subscribe( | ||
| failover.SubscribeAlwaysFailover( | ||
| f.failover, |
Contributor
There was a problem hiding this comment.
Why change only these and not all the other functions, is there something special about these two?
I think the other changes in this PR look reasonable, but I would undo the changes here - I am not aware these endpoints ever caused problems, and changing this could have unintended consequences.
Collaborator
Author
There was a problem hiding this comment.
thanks for catching this. codex went a bit out of scope for this PR, and I missed it, removed.
dd52ec1 to
7b8a2bf
Compare
benma
approved these changes
Mar 4, 2026
Timeouts like server busy - request timed out/context deadline exceeded can happen on slow or overloaded Electrum backends. In this flow we should degrade gracefully, not crash the app. This change removes panic paths in BTC sync/connection handling and ensures async subscription errors trigger failover instead of being silently dropped. The backend now marks the account as fatal/reloads state and keeps the process alive, allowing recovery (e.g. reset to defaults or switch server).
7b8a2bf to
08747ee
Compare
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.
Timeouts like server busy - request timed out/context deadline
exceeded can happen on slow or overloaded Electrum backends.
In this flow we should degrade gracefully, not crash the app. This
change removes panic paths in BTC sync/connection handling and
ensures async subscription errors trigger failover instead of being
silently dropped. The backend now marks the account
as fatal/reloads state and keeps the process alive, allowing
recovery (e.g. reset to defaults or switch server).