Closed thoaionline closed 3 months ago
+1
Vercel docs say server actions need to be async.
https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations
If it is not async, Next throws:
Server actions must be async functions
And revalidateCache needs to be a server action: https://nextjs.org/docs/app/api-reference/functions/revalidateTag
I'm guessing it's not currently async because it isn't possible for the server to actually return the promise?
Canary build refactors the revalidate functions, but none are marked async.
Simplest solution for now is to mark the function async and disable the typescript await rule:
// eslint-disable-next-line @typescript-eslint/require-await
The documentation linked above shows that the function should not be awaited.
1. invalid promise type check
in this repo, under
apps/magic/lib/actions.ts
:then subsequently:
however, the declared return type is
which is not a promise, and thus shouldn't be await-ed.
i checked the implementation here and it's indeed not a promise.
2. promise executor functions should not be async.
there are a couple of
the
async
kindas defeat the purpose of a Promise constructor these days. should be a trivial fix.those 2 issues are the main bugs that come up in sonarcloud from scanning a fresh clone.
i'm happy to make a PR for both but wanted first to check if the
await
was intentional.