#Server actions / revalidatePath / Prisma / Streaming Responses (LangChain)

3 messages · Page 1 of 1 (latest)

teal socket
#

I have a server component that uses prisma.findMany() to get all records from a local dev.db file.
In that server component I have a form with an action prop set to a server action addManyUsers().
addManyUsers runs a loop 50 times, each time adding a new user with random properties.
also, on each iteration of the loop it calls revalidatePath('/').

another server action that I used is addUser() which adds one user to the database and also calls revalidatePath();

When addUser() is run, a ranom user is added to the database and the homepage's data updates with the new user as a result of revalidatePath('/').
However, revaliatePath('/') doesn't run on each iteration of the loop and instead only runs AFTER the loop is over.

So basicclly What I want to happen is:
```
loop x times:
addUser()
revalidatePath('/') # This should update the homepage data


but in reality what happens is:

loop 50 times:
addUser();
revalidatePath('/') # only after the loop is over


I unserstand that revalidatePath('/') only clears the cache and new data will be updated after a clinet side browser refresh but the ui still updates without the need for a router refresh.

// app/(pages)/page.tsx (homepage)

unreal juniperBOT
#

🔎 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)