Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Lost error messages from Server side #32515

Open
present-g opened this issue Mar 4, 2025 · 3 comments
Open

Bug: Lost error messages from Server side #32515

present-g opened this issue Mar 4, 2025 · 3 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@present-g
Copy link

React version:19

Steps To Reproduce

  1. Throw any error from the Server Component.
  2. Check the message in the Error Boundary

The current behavior

In error.tsx (Next.js error boundary), instead of the error message, we get the stub: "An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error."

The expected behavior

We often need to read the specific error message that we throw from the server, so I suggest adding an optional parameter to show the messages.

For example:

// Server Component
throw new Error('Some custom error', { cause: 'TopLevelError' });
// https://github.com/facebook/react/blob/443b7ff2a8437f7736491ae7136c21d75d5a2019/packages/react-client/src/ReactFlightClient.js#L3000
// ReactFlightClient.js

if (__DEV__ || errorInfo.cause === 'TopLevelError') {
        error = resolveErrorDev(response, errorInfo);
      } else {
        error = resolveErrorProd(response);
      }
@present-g present-g added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Mar 4, 2025
@present-g
Copy link
Author

Similar issue on Next's repo

vercel/next.js#71101

@Natthachai-arm
Copy link

React version:19

Steps To Reproduce

  1. Throw any error from the Server Component.
  2. Check the message in the Error Boundary

The current behavior

In error.tsx (Next.js error boundary), instead of the error message, we get the stub: "An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error."

The expected behavior

We often need to read the specific error message that we throw from the server, so I suggest adding an optional parameter to show the messages.

For example:

// Server Component
throw new Error('Some custom error', { cause: 'TopLevelError' });
//


// ReactFlightClient.js

if (DEV || errorInfo.cause === 'TopLevelError') {
error = resolveErrorDev(response, errorInfo);
} else {
error = resolveErrorProd(response);
}

@present-g
Copy link
Author

As a temporary solution, we can use something like this, but I really hope that we will receive an official way to save error messages from the server side.

vercel/next.js#71101 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

2 participants