Skip to content

fix: refresh transaction receipts after reorgs - #5406

Merged
jxom merged 2 commits into
mainfrom
jxom/receipt-reorg-refresh
Nov 3, 2026
Merged

jxom merged 2 commits into
mainfrom
jxom/receipt-reorg-refresh

Conversation

@jxom

@jxom jxom commented Nov 3, 2026

Copy link
Copy Markdown
Member

Refreshes waitForTransactionReceipt receipts once confirmations are met, keeps waiting on transient refresh errors, and keeps the replaced transaction when a reorg removes its replacement. Supersedes #5386.

@vercel

vercel Bot commented Nov 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
viem Building Building Preview Nov 3, 2026 9:36pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 053bfd5

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T21:43:29.037028Z 053bfd5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jxom
jxom merged commit bb7c12c into main Nov 3, 2026
32 of 36 checks passed
@jxom
jxom deleted the jxom/receipt-reorg-refresh branch November 3, 2026 21:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 053bfd5b02

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +312 to +313
if (!replacementResponse) transaction = undefined
replacementResponse = undefined

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recheck the nonce slot after a replacement reorg

When a reorg replaces the already-mined replacement with a different transaction in the alternate chain before this refresh runs, retaining transaction prevents the nonce-slot lookup on subsequent polls. The fallback block scan only examines newly emitted block numbers, so it never sees the new replacement's already-past block and waitForTransactionReceipt can time out even though the nonce slot has a confirmed transaction.

Useful? React with 👍 / 👎.

Comment on lines 292 to 293
)
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Refresh before applying the cached confirmation count

When a reorg re-mines the same transaction in an earlier block, this early return computes confirmations from the discarded receipt and delays reading the canonical one. For example, if the cached receipt was in block 100, the canonical receipt moves to block 99, and three confirmations are requested, at head 101 the canonical receipt is ready but this check sees only two confirmations and waits another block; a timeout during that interval incorrectly rejects an already-confirmed transaction.

Useful? React with 👍 / 👎.

Comment on lines +295 to +299
// A reorg can remove a receipt or change its execution outcome,
// so it is refreshed once it has enough confirmations. Other
// errors keep the cached receipt for the next block.
const receipt_ = await getAction(
client,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Refresh receipts first discovered by the block poll

This refresh only runs when receipt was already cached before the block callback. If the initial lookup returns no receipt and a later block poll first receives one that already satisfies confirmations, the lower fetch path resolves it immediately without this validation; a reorg while that response is in flight can therefore still return the discarded receipt that this change is intended to prevent.

Useful? React with 👍 / 👎.

This branch had an error being deployed

1 failed deployment
Preview — 053bfd5b Deployed Nov 3, 2026 by vercel[bot]
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