Skip to content

Submit and wait (JS): handle TRY_AGAIN_LATER and DUPLICATE, and don't treat a short poll as failure #2962

Closed

Description

@oceans404

Page: https://developers.stellar.org/docs/build/guides/transactions/submit-transaction-wait-js
File: docs/build/guides/transactions/submit-transaction-wait-js.mdx:22-29

What's wrong:
This page defines the submitTx helper that several other guides reuse.

  • It throws on any send status other than PENDING (line 22). TRY_AGAIN_LATER means "resend later" and DUPLICATE means the network already has this transaction, so neither is a failure.
  • It polls only 5 times, 500 ms apart (2.5 seconds), and then treats NOT_FOUND as a failure (line 35). pollTransaction returns the last NOT_FOUND response when it runs out of attempts (v17.4.0 server.ts#L1259), so a transaction that is still pending reads as failed. A caller that retries at that point can send the payment twice.

Change needed:
Explain what each send status means and how to handle it, with TRY_AGAIN_LATER and DUPLICATE handled rather than thrown. Poll long enough for the transaction's time bound, and don't report NOT_FOUND as a failure.

Correct reference:

How to check the fix:

  • Run submitTx against testnet with @stellar/stellar-sdk 17.x: a valid transaction returns SUCCESS.
  • Sending the same signed transaction twice doesn't throw on the second send.
  • Sending two transactions from one account back to back doesn't throw on TRY_AGAIN_LATER.
  • The guides that reuse submitTx still work.
  • pnpm validate passes.

Why it matters: Teams at HackMeridian 2026 learned these rules by losing transactions or nearly paying twice (Lotus, Koul, Ficha).

Related: #2562 and PR #2933 fix the undefined tmpStatus and status variables in the same function; this issue is about the send and poll logic. #2564 (cross-links to the SDK docs). The SDK's own send step also throws on anything but PENDING (v17.4.0 sent_transaction.ts#L85), so the SDK has no helper for this yet.

Activity

  1. stellar-doxie commented on Nov 1, 2026

    @stellar-doxie
    Contributor

    🤖 Automated message from the Stellar Triage Bot.

    I saw this issue. I have not started work on it, because nobody called me in yet.

    How to reach me:

    • Anyone with write permission can call me in. Comment /triage, add the bot:take label, or assign @kaankacar, @ElliotFriend or @wmendes.
    • The issue author can send me away with /triage stop. People with write permission can also add the bot:hands-off label.
  2. added
    bot:take
    on Nov 1, 2026
  3. oceans404 commented on Nov 1, 2026

    @oceans404
    ContributorAuthor

    /triage

  4. stellar-doxie commented on Nov 1, 2026

    @stellar-doxie
    Contributor

    🤖 Automated message from the Stellar Triage Bot.

    Working this because @oceans404 added bot:take.

    I am checking the claims against the SDK and the live page now. I will report back with a PR or a question.

  5. stellar-doxie commented on Nov 1, 2026

    @stellar-doxie
    Contributor

    🤖 Automated message from the Stellar Triage Bot.

    Working this because @oceans404 added bot:take.

    I opened #2977. The claims check out against SDK v17.4.0 and stellar-core.

    • submitTx now resends on TRY_AGAIN_LATER and polls on DUPLICATE.
    • It polls until a ledger closes after maxTime, so NOT_FOUND is never a failure.
    • A new table explains each send status.

    #2933 changes the same lines. The second PR to merge needs a small conflict fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bot:takejs-sdk-v17

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions