-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
redirect in server action and revalidateTag cause a parallel route to lose its active state #64728
Comments
Just found out that if I manually refresh the browser after being redirected to "/" when pressing the Login button, the RSC paylod for the "/login" page is not fetched upon clicking on the add comment button, and everything seems to be working fine from then on. |
When a server action triggers a redirect, we're incorrectly applying a refresh marker to the segment they were on, rather than the segment they were being redirected to. As a result, when revalidation occurs (via `revalidateX` or `router.refresh()`), the top-level segment would be replaced with data for an incorrect segment. For example, if triggering a redirect action from `/redirect` to `/`, the router state tree would save a reference to `/redirect`. The next time a refresh or revalidate happens, it'd refresh the segment data for `/redirect` instead of `/`. Fixes #64728 Closes NEXT-3156
When a server action triggers a redirect, we're incorrectly applying a refresh marker to the segment they were on, rather than the segment they were being redirected to. As a result, when revalidation occurs (via `revalidateX` or `router.refresh()`), the top-level segment would be replaced with data for an incorrect segment. For example, if triggering a redirect action from `/redirect` to `/`, the router state tree would save a reference to `/redirect`. The next time a refresh or revalidate happens, it'd refresh the segment data for `/redirect` instead of `/`. Fixes #64728 Closes NEXT-3156
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://github.com/roksui/my-nextagram
To Reproduce
npm run dev
.Current vs. Expected behavior
I expected the parallel route segment behind the modal to not lose its active state when the router cache is cleared when calling
revalidateTag
in a server action which should only update the data inside the modal. However, I observed that while the data is successfully revalidated in the modal, the parallel route behind the modal loses its active state.Provide environment information
Which area(s) are affected? (Select all that apply)
Parallel & Intercepting Routes
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local)
Additional context
revalidateTag("comments")
is called, the browser receives a RSC payload for the "/login" route. Now, when I removeredirect("/")
inside the server action for the login, this RSC payload is not received after clicking on the add comment button.The text was updated successfully, but these errors were encountered: