Repository navigation
Handle every send status in submitTx and poll until the time bound - #2977
stellar-triage-bot[bot] wants to merge 5 commits into
Conversation
TRY_AGAIN_LATER now resends the same signed transaction, DUPLICATE is treated as pending, and ERROR checks getTransaction first so a resend of an applied transaction does not throw. Polling runs until a ledger closes past maxTime instead of five attempts, so NOT_FOUND is never reported as a failure. Adds a status table and a pollTransaction warning.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
🤖 Automated message from the Stellar Triage Bot. Reviewing my own PR for #2962, which @oceans404 called me in on with
Ready to merge. PR #2933 edits the same lines, so the second one to merge needs a small conflict fix. |
ElliotFriend
left a comment
There was a problem hiding this comment.
This is the most useful PR in the batch, thanks. The status handling checks out against v17.4.0. Two things:
- Rebase needed. #2933 merged and also edited
submitTxinsubmit-transaction-wait-js.mdx(it fixedtmpStatus/statuswith afinalStatusrename). Your rewrite supersedes that hunk, so resolve the conflict in favor of this PR's helper. #2933 also added.setTimeout(30)to the restore transactions inrestore-data-js.mdxandstate-archival.mdx, so yourmaxTimeguard is satisfied there now. - Wording, line 10. "Only
ERRORmeans that the network rejected the transaction" reads as contradicting theTRY_AGAIN_LATERrow, which says the network "did not accept" it. Please reword one of them, e.g. "OnlyERRORis a final rejection."
Optional, but related: restore-contract-js.mdx builds its transaction without setTimeout, so it throws at build() today and would also trip the new guard. Happy for that to be a follow-up issue instead.
|
/triage |
|
Tested One nit on the status table: resending a transaction that's already in a ledger didn't return |
…t-tx-send-statuses # Conflicts: # docs/build/guides/transactions/submit-transaction-wait-js.mdx
…nippets Only ERROR is now called a final rejection. The TRY_AGAIN_LATER and ERROR rows say that a resend of an applied transaction returns TRY_AGAIN_LATER for about 10 ledgers before ERROR (txBAD_SEQ). The restoreContract snippets in restore-contract-js.mdx and state-archival.mdx now call setTimeout(30), which build() and submitTx both require.
|
🤖 Automated message from the Stellar Triage Bot. Back on this because @ElliotFriend asked with /triage and requested changes.
Ready to merge. @ElliotFriend, your change request is still open, so only you can clear it. |
🤖 Automated message from the Stellar Triage Bot.
Closes #2962
Working this because @oceans404 added
bot:take. This PR rewrites the sharedsubmitTxhelper so that it handles every send status and never reportsNOT_FOUNDas a failure.What changes
sendTransactionstatus means and what to do.TRY_AGAIN_LATER: the helper waits 2 s and sends the same signed transaction again, untilmaxTimepasses.DUPLICATE: treated likePENDING. The helper polls for the result.ERROR: the helper callsgetTransactionfirst. A resend of an applied transaction returnsTRY_AGAIN_LATERfor about 10 ledgers, thenERROR(txBAD_SEQ), so this keeps a second send from throwing.SUCCESSorFAILED, or until a ledger closes aftermaxTime. Only then does it throw "expired".pollTransaction()returns the lastNOT_FOUNDwhen its attempts run out (30 by default).restoreContractsnippets inrestore-contract-js.mdxandstate-archival.mdxnow callsetTimeout(30).build()and the newmaxTimeguard both need it.Sources
@stellar/stellar-sdkv17.4.0:SendTransactionStatus(rpc/api.ts:515),pollTransaction(rpc/server.ts:1240-1260), default attemptsDEFAULT_GET_TRANSACTION_TIMEOUT = 30(rpc/server.ts:114),GetTransactionResponse.latestLedgerCloseTime(rpc/api.ts:104).TransactionQueue.cpp:DUPLICATEmeans the same transaction is already queued.TRY_AGAIN_LATERmeans another transaction from the source is queued, or the transaction hash is banned.removeAppliedbans an applied transaction forTRANSACTION_QUEUE_BAN_LEDGERS = 10ledgers (HerderImpl.cpp). After that, an applied transaction fails validation withtxBAD_SEQ.getTransaction:latestLedgerCloseTimeis a string, so the helper wraps it inNumber().submitTxon SDK 17.4.0 against a local network: normal send, resend of a landed transaction,TRY_AGAIN_LATER, expiry, on-chain failure and a missing time bound all behave as the page says.Checks
pnpmis not available in this environment, sopnpm format:mdx,pnpm checkandpnpm check:linksdid not run here. CI runs thechecksjob.Api.GetTransactionResponse. Callers inrestore-data-js.mdxandstate-archival.mdxcompareresp.statuswithSUCCESS, and a narrower type would break them.Notes for reviewers
submitTx, which replaces Fix signing and submission in the archival and simulation examples #2933'sfinalStatushunk.send-and-receive-payments.mdx. I open a separate PR for it.