79294226

Date: 2024-12-19 12:13:09
Score: 1
Natty:
Report link

I'm a bit late here, but I want to share how I "solved" this in my Next JS app, so hopefully someone else does not have to spend as long time as I did.

What I tried:

What I noticed was that refeshing the same page worked fine in the production build. So I tried adding a delay before the server action is executed in the query, and that seems to have worked for developer mode.

const useMyQuery = () => {
  const {
    data,
    isLoading
  } = useQuery({
    queryKey: ['my-query'],
    queryFn: async () => {
      await new Promise((resolve) => setTimeout(resolve, 1));
      // HACK: this somehow fixes the issue where the query doesn't complete
      return await theServerAction();
    }
  });

  return {
    data,
    isLoading
  };
}
Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: MJUlstein