wobsoriano / trpc-nuxt

End-to-end typesafe APIs in Nuxt applications.
trpc-nuxt.vercel.app
MIT License
683 stars 39 forks source link

tRPC returns result on client but never called on backend #183

Open schananas opened 2 weeks ago

schananas commented 2 weeks ago

I just met the craziest issue I have seen and it all points to tRPC Nuxt. (trpc-nuxt: 0.10.21)

Im posting here in hope to understand what happen. Everything started happening after upgrade of the Nuxt and some other dependencies.

I have two onboarding components Step1.vue and Step2.vue

Step1.vue calls:

      await updateUserMutation.mutate({
        name,
      });

This method returns valid result on client site, but backend is actually never called!

Then:

Step2.vue calls:

    await createTeamMutation.mutate({
      name: teamName,
    });

createTeamMutation which is completely different RPC, actually invokes updateUserMutation backend and returns user result instead of team result.

I tried renaming createTeamMutation name to something else in hope it will trigger a recompile, and it worked, but just for a short time, then everything start bugging again. This behavior is reproducible in local dev and in production .

  1. How its even possible that updateUserMutation returns a result without backend being called?
  2. why createTeamMutation actualy invokes updateUserMutation backend?

I have upgraded to 0.10.22, and issue gone away only for initial RPC calls, after that, every next call brings the issue back.

Please help me understand what is going on.

wobsoriano commented 2 weeks ago

Would you be able to create a minimal reproduction I can play with?

schananas commented 2 weeks ago

Il check, it's part of larger application... If it helps I managed to mitigate the bug by adding clearNuxtData() before both method calls on the client. Does it ring a bell?