Skip to content

fix(tron): fail when the broadcast is rejected - #1145

Merged
pedromcunha-uneven merged 3 commits into
relayprotocol:mainfrom
erkancamli:fix/tron-broadcast-failure
Nov 9, 2026
Merged

pedromcunha-uneven merged 3 commits into
relayprotocol:mainfrom
erkancamli:fix/tron-broadcast-failure

Conversation

@erkancamli

Copy link
Copy Markdown
Contributor

TronWeb's sendRawTransaction does not throw when the node rejects a transaction; it resolves with the node's response, for example { code: 'TRANSACTION_EXPIRATION_ERROR', txid, message: <hex> } with result unset. The adapter returned receipt.txid anyway, so the SDK indexed a hash that was never accepted and waited the full confirmation timeout before failing with Transaction confirmation timed out. Leaving the wallet prompt open past the transaction's expiry is enough to hit it.

The adapter now throws Broadcast failed: <decoded message or code> when result is not set, the same way the trigger step already decodes its errors. Changeset included; typecheck and build pass. The tron package has no test runner, so the mock based check stays local.

@vercel

vercel Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

@erkancamli is attempting to deploy a commit to the Uneven Labs Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The Tron adapter now rejects failed broadcasts before confirmation polling, while duplicate broadcasts still continue to confirmation.

  • Tron sends stop when the node rejects a broadcast.

Reviews (4) · Last reviewed commit: "fix(tron): fall back to the error code w..." · Reviewed by Greptile

TronWeb's sendRawTransaction resolves with the node's error instead of throwing, so the adapter returned the txid of a transaction that was never accepted and the SDK waited for the confirmation timeout.
DUP_TRANSACTION_ERROR means the node already has the transaction, so it is not a rejection; return the txid and confirm as before.
const code = String(receipt?.code ?? '')
const isDuplicate = code === 'DUP_TRANSACTION_ERROR' || code === '5'
if (!receipt?.result && !isDuplicate) {
const reason = receipt?.message

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small one: if message isn't hex, this decodes to an empty string and the error is just Broadcast failed: . Could we fall back to receipt.code when the decoded reason is empty?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: when message is not hex the decode comes back empty, so the reason now falls back to receipt.code, and to "Unknown broadcast error" if that is missing too.

…not hex

Buffer.from(message, 'hex') returns an empty string for a message that is
not hex, which left the error as just "Broadcast failed: ".
@pedromcunha-uneven
pedromcunha-uneven merged commit 574be36 into relayprotocol:main Nov 9, 2026
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants