Skip to content

fix: recover ldk restart after background timeout #1125

Description

@ovitrif

What happened?

Backgrounding Bitkit about one second after tapping Restart can make the restart's start() call stall in Electrum fee-rate estimation until its approximately 15-second deadline. The timeout leaves the node lifecycle in ErrorStarting, shows a failure toast, and requires the next foreground resume to trigger recovery.

Unrelated Ktor requests continue succeeding during the stall. The next fee-rate cache update completes in approximately 680 ms.

Expected behavior

The restart flow should recover automatically from a transient fee-rate estimation timeout and return the node to Running without another foreground cycle or manual action.

Steps to Reproduce

  1. Open Settings → Advanced → Dev Settings → LDK.
  2. Tap Restart.
  3. Background Bitkit approximately one second later.
  4. Wait for the restart attempt to finish.
  5. Foreground Bitkit and inspect the node state.

Logs / Screenshots / Recordings

Starting up LDK Node …
Updating fee rate estimates timed out: deadline has elapsed
Failed to start node during restart
LDK Node error: Feerate estimation update timeout.
Fee rate cache update finished in 682ms.

Joao's review evidence includes the full run details and the known-failing restart-while-backgrounded.xml journey.

Bitkit Version

2.4.0 development build from #1122.

Device / OS

Pixel-class arm64 emulator, Android API 36.

Reproducibility

Always — 3/3 with com.synonym:ldk-node-android:0.7.0-rc.62 and 2/2 with 0.7.0-rc.58.

Additional context

restartNode() calls start(shouldRetry = false). A transient start failure therefore commits ErrorStarting immediately, while the next foreground-triggered start can complete the same fee-rate work successfully.

Acceptance criteria

  • Backgrounding Bitkit during Restart does not leave the node in ErrorStarting.
  • A transient fee-rate estimation timeout triggers bounded automatic recovery.
  • Successful recovery returns the node to Running without another foreground cycle or manual restart.
  • Recovered transient failures do not show a terminal restart-failure toast.
  • Automated coverage reproduces the background-during-restart sequence and verifies node usability after recovery.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions