Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: waitForTransactionReceipt race condition when polling many blocks #3068

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

nfmelendez
Copy link
Contributor

@nfmelendez nfmelendez commented Nov 27, 2024

Observe prematurely cleans up when there is still listeners subscribed if one listener call his unwatch many times as this test shows. This problem triggers a race condition in waitForTransactionReceipt, there will be a premature cancel to the poling when one waitForTransactionReceipt get many blocks, therefore will find the same receipt many times and triggers the unwatch many times while other are waiting for their receipt, as is shown in this test:

This Fixes #2650


PR-Codex overview

This PR addresses a race condition in the waitForTransactionReceipt function when polling multiple blocks. It includes tests to ensure proper cleanup of listeners and verifies that transactions do not interfere with each other's receipt polling.

Detailed summary

  • Fixed race condition in waitForTransactionReceipt during block polling.
  • Added a test to ensure cleanup of emit function when the last listener unwatches.
  • Enhanced tests for waitForTransactionReceipt to handle multiple transactions without triggering race conditions.
  • Mocked transaction behaviors to simulate real-world scenarios in tests.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Nov 27, 2024

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

A member of the Team first needs to authorize it.

@jxom jxom merged commit c576800 into wevm:main Nov 27, 2024
2 of 3 checks passed
@github-actions github-actions bot mentioned this pull request Nov 27, 2024
@tmm tmm mentioned this pull request Dec 21, 2024
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 timeout exception after confirmed
2 participants