porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.04k stars 257 forks source link

Next.js: Error: A "use server" file can only export async functions. Found "sql" that is not an async function. #828

Closed jezmck closed 3 months ago

jezmck commented 3 months ago

After updating Next.js from 14.1.1 to 14.1.2, I get

Error: A "use server" file can only export async functions. Found "sql" that is not an async function.

Presumably due to this commit.

porsager commented 3 months ago

So this should be in issue create in the Next.js repo?

jezmck commented 3 months ago

Ah, sorry, I've now realised that it's not this package's own export of sql but mine;

const sql = postgres(process.env.DATABASE_URL as string);
export default sql;
// ...
export async function getLatest...() { ... }