Next.js Discord

Discord Forum

Does 'use server' now implicitly make my exports async?

Unanswered
Alaskan Husky posted this in #help-forum
Open in Discord
Alaskan HuskyOP
Hi, after updating Next from 14.1.0 to 14.2.3, I found that a file annotated with "use server" behaves differently.

"use server"

import { headers } from "next/headers"

export const getCurrentPath = () => {
  const headersList = headers()
  return headersList.get("x-pathname")
}


After a few hours debugging, it seems like "use server" now does some magic to make the exports async.

Is that correct? If so, is there some documentation about that change?

5 Replies

you can't make a sync function running fetch
Alaskan HuskyOP
that's the problem folks, it was working in v14.1.0, and it was exporting synchronous functions.

in v14.2.3, it literally changed the function from sync to async.