next.js
1bca3db0 - fix: redirect should always return updated router state (#85533)

Commit
89 days ago
fix: redirect should always return updated router state (#85533) When a server action triggers a redirect, it will return the RSC payload for the destination state in a single roundtrip. This lets us update the UI without needing to waterfall when getting the target page's data. We reject the server action with a special error signaling that the form state should be reset, but otherwise the redirect itself is unnecessary, since we already are handling it in the server action reducer. However, when we introduced Activity for bfCache, this meant navigating back to the previous page would replay the redirect error that was stashed in the `RedirectBoundary`. I incorrectly patched this by just returning the current router state, rather than the redirect destination's state, but this lost the ability to return the updated state in the same roundtrip as the redirect. Instead, this marks the error that gets stashed in the `RedirectBoundary` as being "handled". Re-activating the hidden subtree will now still correctly reset the state (because the boundary handles it), but won't attempt to perform the redirect again. Closes NAR-470
Author
Parents
Loading