patrick
patrick9mo ago

cache craziness?

can someone sanity check something for me? i'm using sst + trpc + drizzleorm + aws + rds + postgres on the server, and i guess trpc + tanstack-query on the client side... when i do mutations, to say delete something from a list and go optimistically update the client state, via useUtils setData etc... everything is fine... then a few seconds later the browser does a request (tanstack query?) and gets OLD data back from "disk cache" and updates the view to how it was before my mutation! then a few seconds later it updates again with the correct data... i'm having a hard time figuring out which cacheing layer is screwing up... has anyone ever seen such behavior?
2 Replies
BeBoRE
BeBoRE9mo ago
Are you canceling your queries when you are mutating? If you are then I wish you good luck, because that sound pretty tough.
schlabach
schlabach7mo ago
yep... @p.j.n. lmk if you ever figured it out. I am calling setData(...optimisticData) to try and update the cache. When I call getData then it returns the optimistic data. But in the body of my component, trpc is still returning stale data from the server?? Are you using Next? it seems like there might be a bug with the nextjs integration (https://github.com/trpc/trpc/issues/3706) also not sure why but removing the QueryClientProvider seems to fix it...