Skip to content

fix(react): prevent history reads from swallowing pending transaction updates - #493

Open
eCoxvague wants to merge 3 commits into
FhenixProtocol:masterfrom
eCoxvague:fix/receipt-watch-cache-collision
Open

eCoxvague wants to merge 3 commits into
FhenixProtocol:masterfrom
eCoxvague:fix/receipt-watch-cache-collision

Conversation

@eCoxvague

@eCoxvague eCoxvague commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

When a history receipt request starts before the pending-transaction watcher for the same hash, both use ['tx-receipt', chainId, hash]. TanStack Query deduplicates the in-flight request and never invokes the watcher's query function. The receipt arrives, but the persisted transaction remains pending; its mined callback and balance invalidations never run.

Give the lifecycle watcher its own query namespace. History receipts keep their existing keys and public API. This does not change receipt failure, timeout, or cancellation semantics.

Two regressions exercise the collision with a real QueryClient, an in-flight history request, and the actual watcher/store: both successful and reverted receipts incorrectly stay pending on the base revision. With this fix they record the corresponding outcome and fire the mined callback once; only success invalidates balances.

Validation:

  • React unit suite on current master: 29 files, 134 tests passed.
  • pnpm --filter @cofhe/react check:types passed.
  • ESLint on changed TypeScript files and git diff --check passed.
  • One React patch changeset included.

Revalidated after merging current master (88fcba3): the receipt-history collision regressions and all 134 React unit tests, React TypeScript and changed-file ESLint checks passed. Formatting and git diff --check passed. New GitHub Actions runs require maintainer approval for the fork; local verification does not imply those runs have completed.


Note

Medium Risk
Changes query caching for pending tx tracking, which affects store updates and balance refreshes on mine, but scope is narrow and covered by new regression tests.

Overview
Fixes a race where transaction history and CofheProvider's pending watcher shared the TanStack Query key ['tx-receipt', chainId, hash]. When history started first, deduplication meant the watcher's queryFn never ran, so mined txs could stay pending, skip onTransactionMined, and skip balance invalidations.

The lifecycle watcher now uses ['pending-tx-receipt', chainId, hash] so its side effects always run; history keeps tx-receipt and unchanged public behavior.

New parameterized tests simulate an in-flight history fetchQuery plus the watcher and assert confirmed/failed status, a single mined callback, and invalidation only on success.

Reviewed by Cursor Bugbot for commit 0a88bc1. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f606115

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

This PR includes changesets to release 10 packages
Name Type
@cofhe/react Patch
@cofhe/example-react Patch
@cofhe/abi Patch
@cofhe/foundry-plugin Patch
@cofhe/hardhat-3-plugin Patch
@cofhe/hardhat-plugin Patch
@cofhe/mock-contracts Patch
@cofhe/sdk Patch
@cofhe/site Patch
@cofhe/test-anvil 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

@alexshchur alexshchur added the run-matrix Run the matrix and the live testnet suite on this PR with the keys. Add after reading the diff. label Nov 18, 2026
@cursor

cursor Bot commented Nov 18, 2026

Copy link
Copy Markdown

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

@github-actions github-actions Bot removed the run-matrix Run the matrix and the live testnet suite on this PR with the keys. Add after reading the diff. label Nov 18, 2026
@alexshchur alexshchur added the run-matrix Run the matrix and the live testnet suite on this PR with the keys. Add after reading the diff. label Nov 18, 2026
@github-actions github-actions Bot removed the run-matrix Run the matrix and the live testnet suite on this PR with the keys. Add after reading the diff. label Nov 18, 2026

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.

2 participants