fix: node lifecycle race condition after background payment #740
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.
This PR fixes a race condition that caused errors when opening the app shortly after receiving a background Lightning payment.
Description
When a push notification triggers the WakeNodeWorker to process a Lightning payment and the user opens the app immediately after, a race condition could occur between the worker stopping the node and the app trying to start it. This resulted in errors like "The node is already running" or "Cannot execute 'getPayments': node is 'Stopped' and not starting".
Changes:
The bug in error recovery was that
getStatus()returns null when lifecycle state is notRunning(due to its internal guard). During error recovery after a cancelled stop, the state wasStopping, causing the check to always fail and incorrectly set state toStoppedeven though the node was still running.Preview
wake-to-pay.webm
retry-sync.webm
migration-with-cjit.mp4
ln-transactions-after-migration.webm
QA Notes