-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Comments
@jxom @tmm Any thoughts on this one? I think it's an issue with wagmi and not with the react-query devtools tool, since it seems from the react-query documentation the implementing tool needs to supply key-to-JSON parsing scripts, and wagmi appears to be doing it in some cases, but not in this edge case? |
import './bigint-polyfill'; // bigint-polyfill.ts
export interface _BigInt extends BigInt {
toJSON: () => string;
}
(BigInt.prototype as _BigInt).toJSON = function () {
return this.toString();
}; |
@1997roylee that works by making all BigInts be serializable, but in a lossy way. Converting BigInts to strings works in some use-cases where the goal is human-friendliness, but it makes it so the BigInts cannot be de-serialized back to BigInts. The |
https://github.com/wevm/wagmi/blob/main/packages/react/src/utils/query.ts#L82 |
Check existing issues
Describe the bug
When attempting to debug
wagmi
queries with the TanStack devtools, the devtools fails to open if I use bothuseQuery
anduseReadContract
in the same component, if the contract being read withuseReadContract
has bigint values as arguments into the function call. In the JavaScript console it throws an error of:If the component uses only
useQuery
oruseReadContract
, the issue doesn't happen. Only if they're both used. and if theuseReadContract
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
wagmi
v2, with@tanstack/react-query-devtools
v5.66.useQuery
(imported from@tanstack/react-query
) anduseReadContract
(imported fromwagmi
). Note the page renders just fine; both queries succeed.react-query-devtools
view. It fails and in the Javascript console gives an errorWhat 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.
The text was updated successfully, but these errors were encountered: