Repository navigation
fix(api): only expire a pending intent when the network answers NOT_FOUND (#37) - #1107
Merged
DevTobis merged 2 commits intoOct 23, 2026
Merged
Conversation
…OUND (DevTobis#37) The sweep expired any stale intent whose settleIntent threw, so an RPC outage or a failed book update after a successful transaction wrote the transaction off and flagged its line or pledge failed. Expiry now needs a NOT_FOUND answer on the same pass; throws leave the intent pending for the next sweep.
DevTobis
added a commit
to manchesternews98-jpg/ballast
that referenced
this pull request
Oct 23, 2026
The sweep claimed the intent as expired and then applied the failure outside a transaction, so a crash in between left it expired with its line or pledge still pending and no later sweep revisited it (same class as DevTobis#36). Do both in one transaction, as settle does, and count a rolled-back expiry as an error so the next sweep retries it. Drops the rest of this branch: the settle path is already atomic on main (DevTobis#1074) and expiry on NOT_FOUND only is covered by DevTobis#1107.
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.
closes #37
Summary of Changes
sweepPendingIntents(services/api/src/intents.ts), only expire a stale pending intent when the network answeredNOT_FOUNDfor it on this pass. If the outcome lookup throws (RPC outage) or the book update fails after the claim, the intent stays pending, however old, and is retried on the next sweep.settleIntentnow delegates to an internalsettle()that also reports whether the lookup returnedNOT_FOUND. The publicSettleResultshape returned by the/v1/txroutes is unchanged. A plainpendingresult wasn't enough to go on: a caller that loses the claim race re-reads a row that can still be pending when the winner's book update failed.NOT_FOUNDalso covers transactions older than the RPC's retention window (seegetTxOutcome), so an old intent with that answer is still expired. This is noted in a comment at the expiry check.intents.test.ts: rewrote the RPC-error test so it asserts the intent stays pending (no expiry, line not marked failed), and added a test where the book update fails on a stale intent. That intent isn't expired, and the next sweep settles it. The existingNOT_FOUNDexpiry test is unchanged. Both new tests fail against the old sweep.