You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Server action never resolves if router.push in the meantime #74246
I think, in Next.js, performing a router.push or router.replace while waiting for a Promise resolution can cause a conflict. This happens because navigation triggers the component to unmount and remount, interrupting the Promise execution within useEffect. @lcswillems
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.
Activity
aleynaeser commentedon Dec 31, 2024
I think, in Next.js, performing a router.push or router.replace while waiting for a Promise resolution can cause a conflict. This happens because navigation triggers the component to unmount and remount, interrupting the Promise execution within useEffect. @lcswillems
You can revise like
lcswillems commentedon Jan 4, 2025
@aleynaeser It seems your code doesn't work, no?
https://codesandbox.io/p/devbox/affectionate-babbage-yc3yhp
borisghidaglia commentedon Feb 18, 2025
Hey @lcswillems, @leerob suggested to switch to regular route handlers while waiting for a fix.
Demo sandbox: https://codesandbox.io/p/devbox/hardcore-yonath-tjtskf?file=%2Fapp%2Fpage.tsx%3A7%2C30
aleynaeser commentedon Feb 18, 2025
I think it works. Check this => https://codesandbox.io/p/devbox/small-sun-hlyl43
lcswillems commentedon Feb 18, 2025
@borisghidaglia Thank you very much for transmitting! With normal route handlers it works but I need to create ones and I lose the type safety too.
@aleynaeser The router.push should happen in parallel of the fetching, not after.
aleynaeser commentedon Feb 18, 2025
Okay, I updated code. Can u check it again?
lcswillems commentedon Feb 18, 2025
@aleynaeser The router code is still executed after. You await before.
aleynaeser commentedon Feb 18, 2025
Otherwise, how will you see the finished text on the screen? I deleted await and works. But I'm not sure if it's what you think.
leerob commentedon Mar 11, 2025
This should be fixed in v15.2.2. Please try it out, thank you! If you are still seeing issues, we can re-open and investigate.
lcswillems commentedon Mar 11, 2025
Thank you very much!!! 🙏 🙏 🙏
github-actions commentedon Mar 26, 2025
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.