Open nizioleque opened 6 months ago
I also faced same issue
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/keen-newton-f8sxhh?file=%2Fapp%2FProfileLink.tsx%3A12%2C1
To Reproduce
router
function (eg.router.push
) and calls a server action (the order does not matter).In the reproduction:
Current vs. Expected behavior
Expected: The redirect happens immediately, the user sees the new page immediately and the server action runs later in the background.
Current: The redirect happens after the server action is executed.
Attempted workaround: I tried adding a delay between the redirect and calling the server action, but this is not a reliable workaround. I haven't found a working workaround yet.
Additionaly, in my project I notice issues that I could not reproduce in the sandbox: when the redirect eventually happens (after the server action returns), the URL changes but the page contents are not updated - neither the displayed page (server component), nor the return value of
useParams
(client component). This might be related to suspense boundaries but I wasn't able to find the cause.Provide environment information
Which area(s) are affected? (Select all that apply)
App Router, Routing (next/router, next/navigation, next/link)
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local)
Additional context
No response