Random/inconsistent TRPCClientErrors in local environment.

Did a search in here but couldnt find anything relevant. Im making a small game to learn T3 stack stuff and Im having a problem with this autosave interval in combination with prisma/trpc. On most triple mutations there is at least one error on the receiving mutation but it seems totally random. Sometimes its the first one, most times the second or third one fail but its not consistent at all. Is this just a local env problem? Havent tried in production. Did some googling also but couldnt find anything.
4 Replies
Ramsay
Ramsay15mo ago
Are these different mutations doing updates on the same data structure? If so try doing waiting for each mutation to complete rather than calling them all simultaneously or refactor these separate mutations into a single procedure and see if that fixes it. Also see that linter error for your dependency array? As a general rule you should always follow the linter's suggestions for the dependency array.
Taylor
Taylor15mo ago
have covid had so havent been on pc much but I got it working like this lol. Obviously doesnt look ideal. Tried using mutateAsync and did some googleing about combining mutations in react query but couldnt get anything to work. Also It seems weird that the linter wants me to have the useMutation's in the dependency array, doesnt really seem like they should be in there.
Taylor
Taylor15mo ago
but yeah can break easily so not going to keep it going like this
Ramsay
Ramsay15mo ago
The mutations are referentially stable so they won't cause your useEffect to rerun. The linter can't know this so it assumes it is a reactive value. Putting the mutations in or not will not change anything, but it's better to just always follow the linter's suggestions so you don't forget another dependency in the future But yeah I would probably just create one single "save" procedure that does all three of these updates and then just call that one procedure in this useEffect