Next.js Discord

Discord Forum

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

Unanswered
Abyssinian posted this in #help-forum
Open in Discord
Avatar
AbyssinianOP
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)

1 Reply