Repository navigation
Handle TRY_AGAIN_LATER and DUPLICATE in the JS payment example - #2978
Open
stellar-triage-bot[bot] wants to merge 1 commit into
Open
stellar-triage-bot[bot] wants to merge 1 commit into
stellar-triage-bot[bot] wants to merge 1 commit into
Conversation
The example threw on every send status but PENDING. It now resends the same signed transaction on TRY_AGAIN_LATER, treats DUPLICATE as pending, and polls getTransaction until a ledger closes past the time bound, so a slow ledger no longer reads as a failed payment.
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
Contributor
Author
|
🤖 Automated message from the Stellar Triage Bot. Reviewing because this is my own PR for #2963, which @oceans404 called me in on. Verified: the statuses, response fields and |
This branch was successfully deployed
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.
🤖 Automated message from the Stellar Triage Bot.
Closes #2963
Working this because @oceans404 added
bot:take. The JS payment example saidDUPLICATEandTRY_AGAIN_LATERneeded handling, then threw on both. This PR handles them in the code.What changes
In the JavaScript tab of
send-and-receive-payments.mdx:TRY_AGAIN_LATER: wait 2 s and send the same signed transaction again, untilmaxTimepasses.DUPLICATE: treated likePENDING. The example waits for the result.ERROR: still throws.pollTransaction()(default 30 attempts, 1 s apart, then the lastNOT_FOUND) is replaced by agetTransactionloop. It stops atSUCCESSorFAILED, or when a ledger closes aftermaxTime. I included this because the old code reported a slow ledger as a failed payment after about 30 s, while the transaction stays valid for 180 s. That is the double-pay risk the issue names.Sources
@stellar/stellar-sdkv17.4.0:SendTransactionStatus(rpc/api.ts:515),pollTransaction(rpc/server.ts:1240-1260, defaultDEFAULT_GET_TRANSACTION_TIMEOUT = 30at:114,BasicSleepStrategy1000 ms at:231).TransactionQueue.cpp: meanings ofDUPLICATEandTRY_AGAIN_LATER.TransactionFrame::isTooLate: a transaction is too late whenmaxTimeis earlier than the ledger close time.getTransaction:latestLedgerCloseTimeis a string, so the code wraps it inNumber().Checks
pnpmis not available in this environment, sopnpm format:mdx,pnpm checkandpnpm check:linksdid not run here. The CIchecksjob passed.Not changed (follow-ups)
PENDING, and Go gives up after 5 polls.ERROR(txBAD_SEQ) instead.submitTxhelper.