diff --git a/app/src/main/java/to/bitkit/services/LightningService.kt b/app/src/main/java/to/bitkit/services/LightningService.kt
index c867c42243..9b639c2f48 100644
--- a/app/src/main/java/to/bitkit/services/LightningService.kt
+++ b/app/src/main/java/to/bitkit/services/LightningService.kt
@@ -573,10 +573,10 @@ class LightningService internal constructor(
}
this@LightningService.node = null
}
- // Releasing a node whose stop left tasks detached shuts down its tokio runtime under them, and the first
- // one to resume (a VSS write returning, or a thaw from the freezer) aborts the app with "A Tokio 1.x
- // context was found, but it is being shutdown." In the background, kill the process while the runtime
- // is alive instead; a cold start restores everything. In the foreground, release as before.
+ // A stop can leave tasks detached, e.g. a VSS write that keeps retrying. ldk-node keeps their runtime
+ // alive until they end, but the release returns before that, so a rebuilt node could run while the old
+ // node's work still writes. In the background, kill the process instead; a cold start restores
+ // everything. In the foreground, release as before.
if (monitor.hasDetachedWork && isAppInBackground() && exitBeforeRuntimeShutdown()) return@withContext
releaseHandle(node)
Logger.info("Node stopped", context = TAG)
diff --git a/app/src/test/java/to/bitkit/services/LightningServiceTest.kt b/app/src/test/java/to/bitkit/services/LightningServiceTest.kt
index ab51a12ad9..02ea71040b 100644
--- a/app/src/test/java/to/bitkit/services/LightningServiceTest.kt
+++ b/app/src/test/java/to/bitkit/services/LightningServiceTest.kt
@@ -646,7 +646,7 @@ class LightningServiceTest : BaseUnitTest() {
assertNull(sut.node)
}
- // Regression #1536: releasing the node shuts down its runtime under the detached tasks, which abort the app
+ // #1536: in the background, a node with detached work is not released, so its work cannot overlap a rebuilt node
@Test
fun `stop exits the process instead of releasing a node with detached work in background`() = test {
isAppInBackground = true
diff --git a/changelog.d/next/1536.fixed.md b/changelog.d/next/1536.fixed.md
index a13cdb715b..55ec0597c4 100644
--- a/changelog.d/next/1536.fixed.md
+++ b/changelog.d/next/1536.fixed.md
@@ -1 +1 @@
-Fix a rare crash when the Lightning node was slow to stop while Bitkit was in the background.
+Fixed a rare crash when the Lightning node stops while background work is still running.
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 8468eaa12a..bf4e7b28fb 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -69,7 +69,7 @@ ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "k
ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
-ldk-node-android = { module = "com.synonym:ldk-node-android", version = "0.7.0-rc.80" }
+ldk-node-android = { module = "com.synonym:ldk-node-android", version = "0.7.0-rc.81" }
lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version.ref = "lifecycle" }
lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycle" }
lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index e074e6d2ab..ec844f9130 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -4406,6 +4406,17 @@
+
+
+
+
+
+
+
+
+
+
+