Next 14 | Server Actions being spammed
Unanswered
Asian black bear posted this in #help-forum
Original message was deleted.
34 Replies
Shy Albatross
you're misusing server actions, that's why
Server actions are designed for mutations that update server-side state; they are not recommended for data fetching.https://react.dev/reference/react/use-server
also I assume that Next/React has no way of knowing if
prisma.status.whatever
is stable (contrary to fetch, which it expects to be stable based on URL, params and headers, therefore it caches it) so your component that awaits getStatus() rerenders forever?Asian black bear
it works fine in other projects. could it be a next 14 thing?
Shy Albatross
delete the "use server" because there's no reason to go over HTTP when wanting to fetch data between a server function and a server component
Asian black bear
prisma can't run then, might just move it to an api route
Shy Albatross
wdym prisma can't run
Asian black bear
if i remove the 'use server' it won't fetch the data
Shy Albatross
it's still on the server even after you remove "use server"
Asian black bear
tell that to next
Shy Albatross
that's not a next error, that's a prisma error, maybe prisma doesn't support next 14 yet
running in 'unknown'
Asian black bear
this happens in 13 as well
Shy Albatross
so prisma doesn't support RSC?
Asian black bear
it needs 'use server' to run
Shy Albatross
hard to say, their article and demo for RSC are outdated
Asian black bear
it works fine in several other projects. might just move it to an api layer
Shy Albatross
no "use server" here
Asian black bear
because they aren't in a client component
i'm fetching from a client component
Shy Albatross
status is a client component? you failed to include that in the OP
there's no "use client" there
Asian black bear
the page is, forgot to add the screenshot
i will just move it to an api route. not worth the troubles
Shy Albatross
well then I suspect the issue is that the component awaits something that doesn't look like it stabilises so it keeps rerendering forever
at least with an API route you will be aware that you need to secure it somehow
Asian black bear
yeah. i just find it weird because i've been doing this in other projects with no issues
Shy Albatross
I'd like to point out that it's odd that your whole page is a client component
Asian black bear
no need for it to be ssr as it's a dashboard
could go that route, though
yeah just gonna make the page ssr and wrap the interactivity in a client component
Shy Albatross
exactly