Skip to content

fix: sendTransactionSync reports failure for transactions the node already accepted - #5377

Merged
jxom merged 1 commit into
wevm:mainfrom
mmv08:fix/sync-send-node-timeout
Nov 2, 2026
Merged

jxom merged 1 commit into
wevm:mainfrom
mmv08:fix/sync-send-node-timeout

Conversation

@mmv08

@mmv08 mmv08 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

When a node stops waiting for the receipt, eth_sendRawTransactionSync returns error code 4: the node has the transaction, and a later block can still include it (EIP-7966).

With a local account, sendTransactionSync and writeContractSync treated this as a failed send:

  • They threw at once, so an app that retried could send the same transfer twice.
  • They freed the nonce, so the next transaction could reuse it and replace the first one.
  • fallback sent the transaction to the next node, which answered "nonce too low", and Viem lost the hash.

Now, on code 4, Viem keeps the nonce and waits for the receipt until timeout runs out, using the hash in the error. If time runs out, the error names the hash. fallback returns the error instead of trying the next node. Code 4 means this only for eth_sendRawTransactionSync, so other methods still try the next node.

@vercel

vercel Bot commented Nov 2, 2026

Copy link
Copy Markdown

@mmv08 is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b921029

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mmv08
mmv08 force-pushed the fix/sync-send-node-timeout branch from efe1920 to aa4c107 Compare November 2, 2026 13:37
…already accepted

When a node stops waiting for the receipt, `eth_sendRawTransactionSync`
returns error code 4: the node has the transaction, and a later block
can still include it (EIP-7966).

With a local account, `sendTransactionSync` and `writeContractSync`
treated this as a failed send:
- They threw at once, so an app that retried could send the same
  transfer twice.
- They freed the nonce, so the next transaction could reuse it and
  replace the first one.
- `fallback` sent the transaction to the next node, which answered
  "nonce too low", and Viem lost the hash.

Now, on code 4, Viem keeps the nonce and waits for the receipt until
`timeout` runs out, using the hash in the error. If time runs out, the
error names the hash. `fallback` returns the error instead of trying
the next node. Code 4 means this only for `eth_sendRawTransactionSync`,
so other methods still try the next node.
@mmv08
mmv08 force-pushed the fix/sync-send-node-timeout branch from aa4c107 to b921029 Compare November 2, 2026 13:49
@jxom
jxom merged commit 42c41ca into wevm:main Nov 2, 2026
29 of 36 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 2, 2026
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.

2 participants