Skip to content

Handle TRY_AGAIN_LATER and DUPLICATE in the JS payment example - #2978

Open
stellar-triage-bot[bot] wants to merge 1 commit into
mainfrom
docs-agent/2963-payments-send-statuses
Open

stellar-triage-bot[bot] wants to merge 1 commit into
mainfrom
docs-agent/2963-payments-send-statuses

Conversation

@stellar-triage-bot

@stellar-triage-bot stellar-triage-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Automated message from the Stellar Triage Bot.

Closes #2963

Working this because @oceans404 added bot:take. The JS payment example said DUPLICATE and TRY_AGAIN_LATER needed 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, until maxTime passes.
  • DUPLICATE: treated like PENDING. The example waits for the result.
  • ERROR: still throws.
  • Polling: pollTransaction() (default 30 attempts, 1 s apart, then the last NOT_FOUND) is replaced by a getTransaction loop. It stops at SUCCESS or FAILED, or when a ledger closes after maxTime. 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-sdk v17.4.0: SendTransactionStatus (rpc/api.ts:515), pollTransaction (rpc/server.ts:1240-1260, default DEFAULT_GET_TRANSACTION_TIMEOUT = 30 at :114, BasicSleepStrategy 1000 ms at :231).
  • stellar-core TransactionQueue.cpp: meanings of DUPLICATE and TRY_AGAIN_LATER.
  • stellar-core TransactionFrame::isTooLate: a transaction is too late when maxTime is earlier than the ledger close time.
  • Live testnet getTransaction: latestLedgerCloseTime is a string, so the code wraps it in Number().

Checks

  • pnpm is not available in this environment, so pnpm format:mdx, pnpm check and pnpm check:links did not run here. The CI checks job passed.
  • I did not run the example against testnet. I checked it against the SDK and stellar-core source.

Not changed (follow-ups)

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.
@mintlify

mintlify Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
stellar-docs 🟢 Ready View Preview Nov 1, 2026, 10:27 PM

@stellar-triage-bot

Copy link
Copy Markdown
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 maxTime stop rule match SDK v17.4.0 and stellar-core. The preview renders the new code and all checks pass. Ready to merge.

This branch was successfully deployed

1 active deployment
staging — 5b8de2eb Deployed Nov 1, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:ready-to-merge Bot verified and approved; waiting for a maintainer to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Send and receive payments: handle TRY_AGAIN_LATER and DUPLICATE in the RPC example

0 participants