-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
bug: Update to Set (with superjson) not triggering query #5657
Comments
If this is a bug, it's with 95% probability a bug in https://github.com/TanStack/query and not tRPC |
Sandbox with raw RQ: https://stackblitz.com/edit/github-wgxcnf?file=src%2Findex.jsx The first one represents the flow tRPC would work. We don't serialize the input before using is as a query key, so the query doesn't update. We could "fix" this in trpc by transforming input before using is as a query key, although I'm not sure how wise that is 🤔 CleanShot.2024-04-25.at.11.01.12.mp4 |
Yeah, this is most likely an issue in RQ's @BrendanC23 could you open an issue at https://github.com/TanStack/query using @juliusmarminge' sandbox above? |
I created this React Query issue. They will not fix it on their end.
|
Yeahhhhh..... I don't think we'll do this. There are a lot of places we depend on the query hash being whatever RQ produces so I think it'll be quite hairy to make this work. I'd advise you not to use |
You're free to make a PR to implement, but we'd have to update
Not sure if it's worth the squeeze, we've had 3 years of no one reporting an issue related to this so it feels like an edge-case and I'd like us to just piggy-back on RQ's hash fn that works great for the 99% use-case AFAIK, you can still pass the |
This issue has been locked because we are very unlikely to see comments on closed issues. If you are running into a similar issue, please create a new issue. Thank you. |
Provide environment information
Describe the bug
I have a TRPC query like the following
This is called from React with
When the
data
is updated, the TRPC query is not re-run. If I use an array instead of a set, it works fine.I am calling
setData()
with an entirely new object, not mutating an existing object. So the reference is different and React is re-rendering. See the sandbox below.Link to reproduction
https://codesandbox.io/p/devbox/great-leftpad-g69tdw
To reproduce
Click the "Add to Set" button. An element will be added to the Set and the
size
of the local set in React will be updated. However, thesize
returned by TRPC will not be updated, because the query was not re-run.When "Add to Array" is clicked, both the local React
length
and thelength
returned from TRPC are properly updated.The console logs reflect this. Clicking "Add to Set" multiple times will not log that the server query is being run. Clicking "Add to Array" will result in a log for each button click.
Additional information
No response
👨👧👦 Contributing
Funding
The text was updated successfully, but these errors were encountered: