Add server-side background polling to recover stuck Lightning checkouts#28
Merged
danieldaquino merged 2 commits intomasterfrom Feb 26, 2026
Merged
Conversation
Co-authored-by: danieldaquino <24692108+danieldaquino@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix checkout process issues for lightning transactions
Add server-side background polling to recover stuck Lightning checkouts
Feb 25, 2026
danieldaquino
approved these changes
Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Lightning checkouts can get permanently stuck when the client fails to call
POST /ln-checkout/:id/check-invoiceafter paying (browser crash, app switch, network failure). Recovery currently requires the user to manually navigate back to the checkout page.Changes
Background polling (
poll_unpaid_invoices()):PurpleInvoiceManagernow periodically iterates all incomplete checkout sessions with pending invoices and callscheck_checkout_object_invoice()on each concurrently. Interval defaults to 60s, configurable viaLN_INVOICE_POLLING_INTERVAL_MS.Idempotency guard in
check_checkout_object_invoice: Early-returns for already-completed checkouts, preventing redundant LN node queries and double-processing under concurrent client + background poll scenarios.Fix silent payment processing failure:
handle_successful_payment()was not awaited — if it threw, the checkout was markedcompleted = truewhile the account was never updated. Now the error propagates and the next poll will retry.Proper cleanup:
disconnect()now clears the polling interval; test controller teardown callsdisconnect()to prevent timer leaks.Tests
Added
LN Flow — Background polling processes paid invoices without client check: pays an invoice, skipscheck-invoice, callspoll_unpaid_invoices()directly, and asserts the account is activated.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.