fix(payments): log error when LnPayment persist fails#426
Open
Conversation
The LnPaymentsRepository().persistNew() call was not checking for errors, allowing payments to exist in LND but not in MongoDB without any indication of failure. This caused the daily cronjob (checkAndDeletePaymentForHash) to discover these "orphaned" payments and log Critical errors, triggering the Honeycomb cronjob-errors alert every morning at 2 AM when the cronjob runs. Flow before fix: 1. Payment sent via LND successfully 2. persistNew() fails silently (network/db issue) 3. Payment exists in LND, not in MongoDB 4. Daily 2 AM cronjob discovers discrepancy 5. Logs Critical error -> triggers PagerDuty alert Flow after fix: 1. Payment sent via LND successfully 2. persistNew() fails -> immediately logged as Critical 3. Alert fires at time of actual failure, not 24h later Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR improves observability for Lightning sends by logging a critical tracing exception when LnPaymentsRepository().persistNew() fails, preventing silent Mongo persistence failures from only being discovered later by the cronjob.
Changes:
- Capture the result of
LnPaymentsRepository().persistNew()during LN send execution. - Record a
Criticalexception in the current tracing span when persistence fails (returns anError).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Fix silent failure in
LnPaymentsRepository().persistNew()that caused delayed alerts via Honeycomb cronjob trigger.Problem
The
persistNew()call insend-lightning.ts:967was not checking for errors:This caused a cascade of issues:
The Honeycomb Connection
The
galoy-cronjobruns daily at 02:00 UTC (0 2 * * *ingaloy-cronjob.yaml). It executescheckAndDeletePaymentForHashwhich:CouldNotFindLnPaymentFromHashErrorwithErrorLevel.CriticalThis triggers the
cronjob-errorsHoneycomb trigger which:error=trueANDerror.level=criticalover 12 hoursResult: Operators get paged at ~2 AM every morning for payments that failed to persist potentially 24+ hours earlier, with no context about when the actual failure occurred.
Evidence from Honeycomb
Query results show daily
CouldNotFindLnPaymentFromHashErrorevents:app.lightning.checkAndDeletePaymentForHashSolution
Benefits
Test plan
pnpm tsc --noEmit)recordExceptionInCurrentSpanis called correctlypersistNewfailure (e.g., kill MongoDB mid-payment) and verify error appears in the payment's Honeycomb trace with full context (wallet ID, amount, etc.) - not just in a separate cronjob trace 24h later🤖 Generated with Claude Code