-
-
Notifications
You must be signed in to change notification settings - Fork 959
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
Add re-initialization logic for event filters #954
Conversation
@jaxernst is attempting to deploy a commit to the wagmi Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 732a56d The changes in this PR will be included in the next version bump. 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 |
Instead of checking if the filter has errored n times, maybe we can check the error for “filter not found”. Most nodes support this, examples: |
This does make more sense. I was hesitant to do this because I wasn't sure if "filter not found" was standardized, so I looked a bit further. Every client I've checked returns this error except for Erigon: Should we still check for this even if not all clients return it? |
Thought so. Maybe we can keep the current implementation as a fallback, and check the error first? |
Although Erigon doesn't throw a 'filter not found', they do all appear to return a -32000 (Invalid input) error code when the filter isn't found. It looks like Viem already catches these as "InvalidInputRpcError", so might we just reinitialize the filter if we catch an InvalidInputRpcError? |
Implemented this with tests for watchContractEvent and watchEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Will merge it in soon.
* Add reinitialization logic for event filters * Add changeset * fix: auto-reinitialize filters * Update changeset * Update brown-horses-design.md --------- Co-authored-by: jxom <jakemoxey@gmail.com>
Here's my proposal to address #836. Filters can timeout or get into a bad state where reinitialization is necessary to continue getting filter changes on the polling interval. This request adds fallback reinitialization, so if 'getFilterChanges' fails repeatedly, it will attempt to recreate the filter.
PR-Codex overview
Focus of the PR:
This PR focuses on adding filter reinitialization logic for
watchContractEvent
andwatchEvent
when a filter has been uninstalled.Detailed summary:
watchContractEvent
andwatchEvent
when a filter has been uninstalled.InvalidInputRpcError
inwatchEvent.ts
andwatchContractEvent.ts
.watchEvent.ts
andwatchContractEvent.ts
if a filter has been set and gets uninstalled.watchEvent.test.ts
andwatchContractEvent.test.ts
.