Skip to content

Conversation

@jvsena42
Copy link
Member

@jvsena42 jvsena42 commented Jan 27, 2026

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:

  • Adds mutex synchronization to prevent concurrent start/stop operations
  • Adds waiting logic so start() waits for any in-progress stop to complete
  • Fixes error recovery code that incorrectly detected node state after a failed stop

The bug in error recovery was that getStatus() returns null when lifecycle state is not Running (due to its internal guard). During error recovery after a cancelled stop, the state was Stopping, causing the check to always fail and incorrectly set state to Stopped even 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

  1. Ensure the node is stopped (app closed, not in background)
  2. Send a Lightning payment to the wallet
  3. Observe push notification is received
  4. Quickly open the app after receiving notification
  5. Verify:
    • No "node is already running" error in logs
    • No "node is 'Stopped' and not starting" error
    • App displays the received payment correctly
    • Node state shows as Running

@jvsena42 jvsena42 self-assigned this Jan 27, 2026
claude[bot]

This comment was marked as resolved.

@jvsena42 jvsena42 marked this pull request as draft January 27, 2026 16:23
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jvsena42 jvsena42 marked this pull request as ready for review January 27, 2026 17:25
@jvsena42
Copy link
Member Author

OBS: Tested with #738 changes

@jvsena42
Copy link
Member Author

@jvsena42
Copy link
Member Author

jvsena42 commented Jan 27, 2026

@claude

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants