Repository navigation
fix: stop the native abort when the node stops with stuck work - #1999
Conversation
Bumps ldk-node-android to 0.7.0-rc.81 and updates the #1838 stop comments to match it. Verified: just compile, just test, just lint against the published rc.81
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge; no actionable defects were found. SummaryUpdates
No actionable issues were found. Builds and native shutdown behavior were not independently run.
Reviews (1) · Last reviewed commit: "fix: stop the native abort when the node..." · Reviewed by Greptile |
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Bumps ldk-node-android to 0.7.0-rc.81, whose runtime now hands a runtime with undrained detached work to a reaper thread instead of shutting it down under that work, and rewrites the comments on the background exit in LightningService.stop() to match. Reviewed 3abadca, full tier (dependency manifest), static: on bitkit-android the PR's branch is not built here, so this is reasoned from the code, the ldk-node diff and CI.
What I checked, and 3 candidates I ruled out
Read in full: LightningService.stop(), exitBeforeRuntimeShutdown, releaseHandle, awaitNodeRelease, NodeRuntimeMonitor, the #1536 tests in LightningServiceTest.kt; ldk-node src/runtime.rs diff v0.7.0-rc.80..v0.7.0-rc.81 (synonymdev/ldk-node#136, synonymdev/ldk-node#138) and the block_in_place call sites in src/io/vss_store.rs.
Release: tag v0.7.0-rc.81 is 366d56e on ldk-node main; its only code change is src/runtime.rs, and the release notes say no API changes. The native-debug-symbols.zip checksum in verification-metadata.xml matches the release asset's digest; the .aar and .module hashes were accepted by Gradle verification in build-and-test.
Monitor still fires: rc.81 keeps the three Detaching ... error lines NodeRuntimeMonitor matches on (runtime.rs:412, :443, :484), so the background exit still triggers on the same signal.
CI: build-and-test green; lint, build-local and compose-ui / ui-tests still running at review time.
Ruled out
- Foreground release now lets the old node's stuck VSS write land after a rebuilt node starts: the write completes inside the internal VSS runtime before the task touches the node runtime's timer, so it landed before the abort on rc.80 too. The overlap is not new; only the abort that followed it is gone.
- Reaper keeps a runtime alive forever when the work never ends: bounded to one runtime per stuck stop, and it is ldk-node's deliberate trade-off in #138, not code in this diff.
- Comment now overstates the fix: it says what rc.81 does (runtime kept until the work ends,
destroy()returning after the 5 s drain) and why the background exit stays.
Merge confidence: 4/5, the stuck-stop path is tested only in ldk-node and the bump's on-device behaviour rests on CI's E2E jobs, which were still running.
Reviewer model: Claude Opus 5.5
Reasoning effort: Not exposed (the review run's metadata does not report it)
coreyphillips
left a comment
There was a problem hiding this comment.
Two independent reviews, nothing blocking a merge.
worth doing, does not block
- Release kdocs still claim no overlap with the old node, which rc.81 no longer gives (app/src/main/java/to/bitkit/services/LightningService.kt:596-623). After this bump, the kdocs on
releaseHandleandawaitNodeReleasepromise something the code no longer gives. They say the gate means a rebuild or storage wipe "never overlaps the old node's native lifetime" (LightningService.kt:604 and :620). In rc.81,Runtime::shutdown(ldk-nodesrc/runtime.rs:100-112atv0.7.0-rc.81) handles work still running after the 5 s drain differently. It passes the runtime to a reaper thread and returns, sofree_nodereturns too. In the foreground,awaitNodeReleasethen opens while the old node's detached work is still running and can still write. The comment this PR rewrote at :576-579 now says exactly that, so it contradicts the two kdocs just below it.exitBeforeRuntimeShutdown(:585) is also named for the old reason (runtime shutdown) rather than the new one (overlap). Suggest saying in the kdocs that the gate waits forfree_node, not for detached work, so nobody relies on it for that. I confirmed this by reading the rc.81 runtime source against these kdocs. - QA notes say the stuck stop can't be triggered, but the issue has a recipe. The Gaps note says the stuck-stop path cannot be triggered on demand, so the only evidence is ldk-node's unit tests. The issue's 19 Oct comment disagrees: an iptables DROP on VSS (
34.65.252.32:443) on agoogle_apisemulator produced the timed-out stop withDetaching background tasks after cancellation timed out.on every run. In the background that stop now ends in the #1838 process exit. rc.81's new path only runs on a foreground stop. One way to trigger it: 1. Block VSS. 2. Wait for a wallet sync to hang on itsnode_metricswrite. 3. Restart the node from the foreground, e.g.restartWithElectrumServerby changing the Electrum server in Settings. Expected log order: 1.Detaching …2.Deferring runtime shutdown until detached work still running at shutdown has ended.3. After the network is restored:Shut down the runtime after detached work ended.There should be no abort. A run of this would be the first evidence in the app for the top crash on 3.1.1. I did not run it myself.
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR diff against its merge base, at 3abadca9.
1 actionable finding — resolve or provide an evidence-backed rebuttal.
ldk-node-android 0.7.0-rc.81 is tag 366d56ef. Against v0.7.0-rc.80 the only library code change is src/runtime.rs: when detached work is still running, shutdown hands that runtime to a reaper and returns, instead of calling shutdown_background under it. The three Detaching … error lines NodeRuntimeMonitor matches are unchanged, so the background process exit still keys off the same signal. A foreground stop still calls destroy().
The releaseHandle and awaitNodeRelease kdocs still say free_node returns only after background tasks drain and that the gate keeps a rebuild or wipe from overlapping the old node's native lifetime. This shutdown returns while that work can still run.
Compared with bitkit-ios#1394 at 45ff9d4, which pins the same 0.7.0-rc.81 revision. iOS drops the node after stop() and has no process exit. Android still exits the process when that detach log was seen and the app is in the background. Only this shutdown contract was compared.
Device testing: not performed in this review. The checks on 3abadca9 show build-and-test, lint, detekt, compose-ui / ui-tests, and the local e2e shards succeeded. This review inspected those results. They do not assert the stuck-stop path. LightningServiceTest still covers the background-exit decision. The native deferral is in the ldk-node runtime.rs tests, which were read and not executed here. Gradle verification for the rc.81 AAR, module, and native debug symbols is present in the same shape as rc.80, and build-and-test accepted the checksums it resolved.
Suggested additional test cases
Android regtest on a rooted API 35 emulator, fresh wallet, node running. Block TCP 443 to bitkit.stag0.blocktank.to (the non-mainnet VSS URL in Env) and leave Electrum reachable. Keep the app in the foreground for the whole stop: the background path calls exitProcess before destroy(). Change the Electrum server so restartWithElectrumServer stops and rebuilds the node. Expected logs: Detaching background tasks after cancellation timed out., then Deferring runtime shutdown until detached work still running at shutdown has ended., and no SIGABRT. After unblocking VSS: Shut down the runtime after detached work ended. This adapts the stop recipe in issue 1536.
Findings
- [LOW] State that the release gate does not wait for detached work — inline at
app/src/main/java/to/bitkit/services/LightningService.kt:577.
Reviewer model: grok-4.7
Reasoning effort: xhigh
|
Merging: approved by @coreyphillips and @piotr-iohk on this head, required checks green, @piotr-iohk's kdoc point tracked in #2003. |
@coreyphillips The kdocs are tracked in #2003 and get fixed in the next ldk-node bump PR, along with the |
@coreyphillips Ran it on rc.82 in #2004: the log order matched ( |
Closes #1536
Twin: synonymdev/bitkit-ios#1394
Updates
ldk-node-androidto 0.7.0-rc.81, which carries synonymdev/ldk-node#136 and synonymdev/ldk-node#138.Description
A Tokio 1.x context was found, but it is being shutdown., the top crash on 3.1.1 (14 of 18 crash events on build 197).LightningService.stop()and its test to describe why it stays, and widens the changelog fragment to every stop.gradle/verification-metadata.xml.Out of Scope
releaseHandleandawaitNodeReleasestill say the release gate waits for detached work: docs: node release gate does not wait for detached work #2003, from this thread.Design
N/A — no UI changes.
Preview
N/A
QA Notes
Setup
Regtest build.
Journeys
N/A — no user-visible behaviour change.
Manual Tests
N/A
Automated Checks
try_block_onand directly inblock_in_place. They check that shutdown does not wait for it, that its next timer poll does not panic, and that the runtime shuts down once it ends.Evidence
just compile,just test,just lintpass against the publishedcom.synonym:ldk-node-android:0.7.0-rc.81.Gaps
Models used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium),Claude Sonnet 5.5(reasoning:high)Claude Sonnet 5.5(reasoning:high)