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

TanStack Query Devtools failing to parse BigInt #4546

Open
1 task done
MidnightLightning opened this issue Feb 15, 2025 · 0 comments
Open
1 task done

TanStack Query Devtools failing to parse BigInt #4546

MidnightLightning opened this issue Feb 15, 2025 · 0 comments

Comments

@MidnightLightning
Copy link

MidnightLightning commented Feb 15, 2025

Check existing issues

Describe the bug

When attempting to debug wagmi queries with the TanStack devtools, the devtools fails to open if I use both useQuery and useReadContract in the same component, if the contract being read with useReadContract has bigint values as arguments into the function call. In the JavaScript console it throws an error of:

Uncaught (in promise) TypeError: Do not know how to serialize a BigInt
    at JSON.stringify (<anonymous>)
    at hashKey (chunk-6Y4SHYZR.js?v=c0e65ea7:123:15)
    at hashQueryKeyByOptions (chunk-6Y4SHYZR.js?v=c0e65ea7:120:10)
    at matchQuery (chunk-6Y4SHYZR.js?v=c0e65ea7:69:31)
    at chunk-6Y4SHYZR.js?v=c0e65ea7:1098:18
    at Array.find (<anonymous>)

If the component uses only useQuery or useReadContract, the issue doesn't happen. Only if they're both used. and if the useReadContract target function doesn't take a bigint value as input, it doesn't happen.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/new-wagmi-qqhzxm

Steps To Reproduce

  • Install wagmi v2, with @tanstack/react-query-devtools v5.66.
  • In one component, use both useQuery (imported from @tanstack/react-query) and useReadContract (imported from wagmi). Note the page renders just fine; both queries succeed.
  • Attempt to open the react-query-devtools view. It fails and in the Javascript console gives an error

What Wagmi package(s) are you using?

wagmi

Wagmi Package(s) Version(s)

2.14.1

Viem Version

2.7.9

TypeScript Version

5.0.4

Anything else?

This was originally experienced as #3328, under wagmi v1. After upgrading to v2, the issue persists, and I've narrowed it down to just this situation of combining two different types of react-query calls.

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

No branches or pull requests

1 participant