How to fix or disable this error in production mode "An error occurred in the Server Components render..." #71099
-
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 4 replies
-
You have to look at the logs of your app, with the digest number you get in the error. That being said, I guess, the issue is at the login step. Could you add more logs to the login? |
Beta Was this translation helpful? Give feedback.
-
I have gotten a solution to it. So, the issue comes from the error logging to the terminal. In production nextjs try to protect the app from releasing sensitive information to client because it cannot tell if the error is internal or external. So, the solution was to find a different method to log the error to the user. "client side code (login page function)" "Server side code (Action)" |
Beta Was this translation helpful? Give feedback.
-
did you solve it ?? |
Beta Was this translation helpful? Give feedback.
-
This does not make sense. It's developer's responsibility to hide technical messages. In my case I have a BusinessError class inheriting from Error. This error type should be visible in client as is since I create messages for user :) There are solutions like returning some kind of object like: { status: "OK", result = ...} or { status: "Error", value: "Invalid usr/pwd combination } But in this case you cannot design a centralized error management/logging on server. You have to use try/catch statements inside all server actions. |
Beta Was this translation helpful? Give feedback.
-
I created an issue. |
Beta Was this translation helpful? Give feedback.
-
Yes, I have a solution
…On Wed, May 14, 2025 at 7:08 AM mikey ***@***.***> wrote:
"Server side code (Action)"
Did you find a solution apart from hiding exception?
—
Reply to this email directly, view it on GitHub
<#71099 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIIR3VUMNBSQP2KQMNTWXID26LTWRAVCNFSM6AAAAABPXA44I2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMJUGA4DQOI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
The larger issue at hand is the lack of dev/prod parity, and this goes against the "principle of least astonishment." I have some sympathy for the fact that the Next team doesn't allow exceptions to flow through to the client (although I believe this should be a config option). But the part that I am troubled by is why my dev environment differs from production. This does not give me confidence that there aren't other land mines in my codebase! As developers, we expect our local environment to mimic production as closely as possible when possible. Local development in this instance should show the same exception that production does. Much of this problem goes away because teams handle server-side errors differently from the start. |
Beta Was this translation helpful? Give feedback.
I have gotten a solution to it. So, the issue comes from the error logging to the terminal. In production nextjs try to protect the app from releasing sensitive information to client because it cannot tell if the error is internal or external.
For example:
If the error is coming from a third-party service, you are using it might contain sensitive info like api-key, user ids, etc.
So, the solution was to find a different method to log the error to the user.
"client side code (login page function)"
"Server side code (Action)"