Issue with triggering the primary not-found.tsx file of the App Router on each refresh. #70253
Unanswered
mmdrn
asked this question in
App Router
Replies: 3 comments
-
Update: I removed the entire |
Beta Was this translation helpful? Give feedback.
0 replies
-
Update: I discovered the issue was related to the |
Beta Was this translation helpful? Give feedback.
0 replies
-
The issue still exist |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Issue with Global
not-found.tsx
in Next.js Application Using Both Pages and App RoutersI have a Next.js application that uses both the Pages Router (for legacy pages) and the App Router (for some migrated routes). From my understanding, when both routers exist in a single project, the global
not-found.tsx
file in the App Router gets used for 404 errors in the Pages Router as well. In other words, when the Pages Router encounters a 404 error, instead of rendering its own404.tsx
file, thenot-found.tsx
file from the App Router is triggered.First of all, please correct me if my understanding is wrong.
The Main Issue
After adding a global
not-found.tsx
file in the App Router and deploying it to production, we noticed via Sentry logs that it was triggered 15,000 times (as shown in the attached image).My question is: why is this happening? Is this behavior expected in Next.js when using the
not-found.tsx
file, or could there be something wrong in my application? Why is this file running even when the not-found page is not triggered??Additional Context
While debugging, I added a
console.error
statement in thenot-found.tsx
file. After building and starting the project, I noticed the following:not-found.tsx
file gets triggered, and theconsole.error
is logged whenever I refresh pages that are implemented using the App Router.Any insights into why this behavior occurs and whether it's normal or an issue with my setup would be greatly appreciated!
The code of the
not-found.tsx
:Beta Was this translation helpful? Give feedback.
All reactions