#Server Action Caching

2 messages · Page 1 of 1 (latest)

tiny plover
#

I have a server action function such as:

'use server'

...

export async function continueWithEmail(formData: FormData) {
  const maybeEmail = formData.get('email');
  const parseResult = z.string().email().safeParse(maybeEmail);

  if (!parseResult.success) {
    return parseResult.error.format();
  }

  const email = parseResult.data;

  const result = await authClient.magicLinks.email.discovery.send({
    email_address: email,
  }); // 3rd party SDK

  console.log('email resultId: ', result.response.request_id);

  return redirect('/signup/continue-with-email/success');
}

that seems to be caching the call to authClient.magicLinks.email.discovery.send (this is probably using fetch behind the scenes but this is an SDK so I have no control over that fetch).

the console.log with the request_id is always the same, which indicates that that call is being cached.

how do I disable caching in this server action?

I already tried things like export const revalidate = 0 but nextjs complains that I can only export async functions from a server action file.

any ideas? 🙏

thanks!

charred isleBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)