Closed sarthak61199 closed 2 weeks ago
Hi, what version of ZSA are you using? This was patched in later versions
Hi,
Thanks for the quick response , I'm using the following zsa versions ->
"zsa": "^0.3.4", "zsa-react-query": "^0.1.0"
Those versions should be good. For reference, here is the line that checks for redirects or not founds:
if (err.message === "NEXT_REDIRECT" || err.message === "NEXT_NOT_FOUND")
I wonder if your redirect error maybe has a different message that we aren't catching? Do you have a log of the final error you are getting returned? Curious what the message is in that error.
Hi,
I just did some digging. Here are some findings ->
-> I printed the error on console and got "TypeError: undefined has no properties" -> The error seems to be coming in the following code block
const useServerActionMutation = (action, options, queryClient) => {
return useMutation(
{
...options,
mutationFn: async (...args2) => {
const [data, err] = await action(...args2);
if (options?.returnError) {
return [data, err];
}
if (err) {
throw err;
}
return data;
}
},
queryClient
);
};
Thanks for catching this! Seemed like it was only an issue with react query mutations. Please give zsa-react-query@0.1.1
a shot 🙏
Thanks. Ill give it a try and report back
It's working now, thank you so much for this amazing library!
Awesome 🫡 Happy to help. If you find any more issues please make an issue and will fix ASAP.
Hi,
When using redirect function in a server action made using ZSA library, it catches the error thrown internally in redirect and returns an error even if the server action was successful. I even tried moving the redirect function call to onSuccess callback but I got the same result.
Reference -> https://nextjs.org/docs/app/building-your-application/routing/redirecting