next.js
next.js copied to clipboard
Error: NEXT_REDIRECT crashing server in prod
Verify canary release
- [X] I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System: Platform: win32 Arch: x64 Version: Windows 10 Pro Binaries: Node: 16.15.1 npm: N/A Yarn: N/A pnpm: N/A Relevant packages: next: 13.0.3-canary.0 eslint-config-next: 13.0.2 react: 18.2.0 react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome Version 107.0.5304.88
How are you deploying your application? (if relevant)
Vercel and localhost in prod environment
Describe the Bug
Looks similar to #42556, but this issue is based on the server crashing
Whenever I run yarn build && yarn start
and visit http://localhost:3000/dashboard
i receive this error:
The route /dashboard
is set to route a user back to /
if not logged in. This is done in a SC via the redirect()
function.
This error crashes the server and I have to restart it, on a vercel deployment I just get a 500 error.
Expected Behavior
I expect the page to redirect the user to the desired URL without the server crashing.
Link to reproduction
https://github.com/OMikkel/next_redirect_repro
To Reproduce
- Clone git repo above
- Run yarn install
- Run yarn build
- Run yarn start
- Go to /dashboard
- Restart the app
- Try again
We might have a similar Issue with NOT_FOUND_ERROR_CODE
:
/usr/src/app/.next/server/chunks/325.js:5261
const error = new Error(NOT_FOUND_ERROR_CODE);
^
Error: NEXT_NOT_FOUND
at notFound (/usr/src/app/.next/server/chunks/325.js:5261:19)
at load (/usr/src/app/.next/server/app/[...slug]/page.js:710:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
digest: 'NEXT_NOT_FOUND'
}
error Command failed with exit code 1.
We use StoryBlok and if we don't find the slug, the server crashes instead of showing the 404 page.
@adrian-goe can you create a separate issue with a reproduction, thanks!
I am experiencing the same issue as well!
We are also experiencing issues with redirects (getServersideProps) after upgradring. In 13.0.0 the client performed a request to a unknown chunk after loading a page with a redirect in getServerSideProps - and in 13.0.3 this request disapeared but we are still getting an error logged that the route was not found when the redirect target is loaded. The redirect is to the same page but with a prettified url having more query params etc. Everthing works as expected but it's annoying to constantly get an error from route loader. Will try and recreate the issue in a barebones project as we have some additional stuff around the router and a custom server to support prettified and localized urls in our application. Might be out setup.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.