T
tRPC

Sometimes invalidate not work...

Sometimes invalidate not work...

Mmelodyclue7/20/2023
hello sometimes invalidate method does not work in onSuccess anyone same? using NextJS, pnpm
No description
TTypedef8/18/2023
Im having this problem aswell, @melodyclue have you found a solution?
Mmelodyclue8/18/2023
well, The problem is solved by writing an invalidate directly after the asynchronous process, instead of "onSuccess". We do not know why "onSuccess" does not work. In some cases it works, so I am confused.
TTypedef8/18/2023
are you still invalidating through useContext? but just after the async
Mmelodyclue8/20/2023
yes I use ``` const utils = trpc.useContext() ... onSuccess() { utils. .... .invalidate() }
TTypedef8/22/2023
Ahh, in my case onSuccess works all the time, but the utils...invalidate() doesnt.
DDavid9/22/2023
How did you solve this? cc @melodyclue
Mmelodyclue9/22/2023
@David In fact, it has not been resolved. It seems that invalidating within onSuccess does not execute. However, there are some that are executed and I am confused. For now, directly in the function await utils.project.getProject.invalidate({ project_id: projectId }); in the function for example, it seems to be executed.
DDavid9/22/2023
Damn that is rough, thanks for the quick response! A follow up question, do you happen to have 2 QueryClientProviders in your tree?
Mmelodyclue9/22/2023
@David 🧐 no, I dont use QueryClientProviders. instead I use export default trpc.withTRPC(App)
DDavid9/22/2023
I figured, thanks for the info! It seems that doing this:
const queryClient = useQueryClient()

// onSuccess
await queryClient.invalidateQueries(getQueryKey(trpc.path.to.query))
const queryClient = useQueryClient()

// onSuccess
await queryClient.invalidateQueries(getQueryKey(trpc.path.to.query))
Mmelodyclue9/22/2023
@David so useQueryClient is the key to solve this problrem? I will try !
DDavid9/22/2023
Bit of a workaround
TTypedef9/22/2023
I had 2 queryClient providers thats why mine wasnt working 👍🏽
Mmelodyclue9/25/2023
@David oh you are talking about v9. mine is v10 actually...
DDavid9/25/2023
Nope, talking about v10 but later realized that also is not consistent it seems
Mmelodyclue9/25/2023
@David I think await queryClient.invalidateQueries(getQueryKey(trpc.path.to.query)) is the way how it works on v9 🤔
DDavid9/25/2023
It's just one of the standard react-query ways to do it
Mmelodyclue9/25/2023
@David ok figured out! you're right David. And this issue (invalidate not works) is fully resolved !!! https://trpc.io/docs/client/react/getQueryKeytrpcold

Looking for more? Join the community!

T
tRPC

Sometimes invalidate not work...

Join Server
Recommended Posts
trpc client request size limits?I am sending a pretty sizable request and am seeing ``` [TRPCClientError: JSON Parse error: UnexpecMake tRPC return Bad Request on Zod validation error?As the title says, how can I make tRPC return a proper error message, like a Bad Request, when thereUsing proxyClient in vercel edge functionHey guys, i want to call my trpc apis inside vercel edge functions. Edge runtime does not have all cookies not being set in procedureThis is all the code for setting my cookie ```js import { publicProcedure, router, userProcedure } fuseSubscription simplified with react queryHi Guys, looking for a way to simplify the use of useSubscription. Currently I do the following: 1Next.js app router catch-all HTTP methodsThe app router already supports the catch-all file for route resolution, but AFAIK still expects sepTRPC Vanilla Client (T3 stack)I'm using the T3 stack (Next + TRPC + etc) and I'm trying to figure out how to do vanilla queries thMultiple Inputs on TRPC Procedure?Essentially I'm trying to pass a cart (array of objects) into a public procedure (doing so fine). I adapter for hono or hattip?we’ve got adapters for express, stand alone node and next. I wonder how easy would it be to make adKeep getting 500 error response I can't figure outWith both queries and mutations I get back this response saying that there's html in the response antRPC & redux toolkit queryNode 18, pnpm, ts, vite, toolkit. Cant find any proper info how to use tRPC with toolkit query; If Ihow can I globally set a "middleware" callback for all onErrors on my React Query calls?this is a little specific but Im struggling on it Im using the TRPC server as a BFF for my backend Upgrading from tRPC v9 and NextJS v12. Should I upgrade NextJS first or tRPC?I have an app built from the tRPC + NextJS + Prisma starter, and I'd like to upgrade from tRPC v9 anprefetchinfinite not working when inputs are differentIve been trying to figure out why prefetching doesnt work when the inputs are different between preftRPC + App directory + SSR - current state?What is the current state of the technologies working together with or without SSR? It looks like soHydration failed because the initial UI does not match what was rendered on the server```Unhandled Runtime Error Error: Hydration failed because the initial UI does not match what was reReact tsc starts checking server typesMy tsconfig files are different on the server and client. When I run "tsc" on react client, It is trNextJS 13 Build failingIssue also seen in this PR  https://github.com/trpc/trpc/pull/4574 I found. None of the webpack workGoogle OAuth callbackany one help how to handle google oauth callbackurl using tRPCInfering query/mutation callback opts parameterHey 🙂 Thanks for your hard work on this awesome library. I want to create tRPC router, but i want