Skip to content

fix: send a new receipt request for each block in waitForTransactionReceipt - #5662

Open
frontier159 wants to merge 1 commit into
wevm:mainfrom
frontier159:fix/wait-receipt-concurrent-block-dedupe
Open

frontier159 wants to merge 1 commit into
wevm:mainfrom
frontier159:fix/wait-receipt-concurrent-block-dedupe

Conversation

@frontier159

Copy link
Copy Markdown
Contributor

Fixes #5661.

getTransactionReceipt dedupes: if the same client has sent an identical request and is still waiting for its response, a new call returns that response instead of sending its own request. When waitForTransactionReceipt checks a new block, that earlier request may have been sent before the block arrived, so its response can say there is no receipt for a transaction in the block. If the node then mines no later block, as anvil without interval mining does, the wait times out on a mined transaction.

getTransactionReceipt now takes dedupe (default true, so its behavior does not change). The receipt lookups inside waitForTransactionReceipt's block check pass dedupe: false, so each sends its own request after its block arrived. The wait's first lookup, before polling starts, still dedupes. Nothing else changes: the scheduling of block checks, the replacement search and confirmations are as before.

Cost: while a transaction is pending, the wait sends one receipt request per new block, where main sent one per poll. When one poll finds several new blocks, the wait sends a request for each: about 2× the receipt requests on Arbitrum at the default polling interval, and almost no change on Ethereum, Base or BSC. Waits on one client also stop sharing receipt requests with each other.

Alternatives considered:

  • Calling eth_getTransactionReceipt directly inside the wait, without a new option. Ruled out: it would skip a client's override of getTransactionReceipt, which the wait honors through getAction.
  • Checking blocks one at a time, so a later check starts after the earlier one finishes. Ruled out: it changes how the wait schedules block checks, and with a slow node on a fast chain the replacement search fell behind the chain (measured: a wait pending 60 s resolved 31 s after mining, against 1.3 s on main).

Tests:

  • waitForTransactionReceipt: the transport receives anvil's answer to a block check's receipt request (no receipt), mines the transaction's block, and returns that answer only after the client has polled the new block number. The new block's check starts while that request is still waiting. It times out on main and passes with this change.
  • getTransactionReceipt: a call made while an identical request is still waiting, after the transaction was mined, gets "not found" by default and the receipt with dedupe: false. It fails with dedupe always on.

…eceipt

getTransactionReceipt dedupes: if the same client has sent an identical
request and is still waiting for its response, a new call returns that
response instead of sending its own request. When
waitForTransactionReceipt checks a new block, that earlier request may
have been sent before the block arrived, so its response can say there
is no receipt for a transaction in the block. If the node then mines no
later block, as anvil without interval mining does, the wait times out
on a mined transaction.

getTransactionReceipt takes `dedupe` (default `true`). The receipt lookups
inside waitForTransactionReceipt's block check pass `dedupe: false`, so
each sends its own request after the block arrived. The wait's first
receipt lookup, before polling starts, still dedupes.
@vercel

vercel Bot commented Nov 25, 2026

Copy link
Copy Markdown

@frontier159 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 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 36d3705

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

This branch has not been deployed

No deployments
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.

waitForTransactionReceipt times out when the transaction's block arrives while an earlier receipt request is still waiting for its response

1 participant