fix: show error details in preview environments#8752
fix: show error details in preview environments#8752ZeroPointSix wants to merge 4 commits intonodejs:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
👋 Codeowner Review RequestThe following codeowners have been identified for the changed files: Team reviewers: @nodejs/nodejs-website Please review the changes when you have a chance. Thank you! 🙏 |
There was a problem hiding this comment.
Pull request overview
Updates the localized Next.js App Router error page to optionally reveal underlying error information in non-production contexts, addressing missing diagnostics in Vercel Preview and local development (Fixes #7464).
Changes:
- Add a
SHOW_ERROR_DETAILSenvironment-derived flag to gate error detail rendering. - Render error
messageanddigestin a<details>block on the localized 500 error page when the flag is enabled. - Add a unit test to cover the “details visible” rendering path.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| apps/site/tests/errorPage.test.jsx | Adds a unit test asserting that technical details render when SHOW_ERROR_DETAILS is enabled. |
| apps/site/next.constants.mjs | Introduces SHOW_ERROR_DETAILS based on NODE_ENV and VERCEL_ENV. |
| apps/site/app/[locale]/error.tsx | Shows error message/digest in preview/dev via a gated <details> section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Note Your Pull Request seems to be updating Translations of the Node.js Website. Whilst we appreciate your intent; Any Translation update should be done through our Crowdin Project. Thank you! |
|
I pushed a follow-up commit that addresses the preview/client environment handling, adds a dedicated error-page details key, and covers the hidden-details path in tests. I also noticed the repository policy requires the github_actions:pull-request label to trigger the full PR checks. I don't have permission to add labels on the upstream PR from the fork side, so could a maintainer please add it when convenient? Thanks! |
|
I pushed a small follow-up to align with the translation guidelines: the new layouts.error.details key now only lives in packages/i18n/src/locales/en.json, and other locales fall back to English via the existing dictionary merge in apps/site/i18n.tsx. That keeps the PR focused on the preview-error fix while still using a dedicated error-page key. |
apps/site/next.config.mjs
Outdated
| basePath: BASE_PATH, | ||
| // Vercel/Next.js Image Optimization Settings | ||
| images: getImagesConfig(), | ||
| env: { |
apps/site/app/[locale]/error.tsx
Outdated
|
|
||
| const ErrorPage: FC<ErrorPageProps> = ({ error }) => { | ||
| const t = useTranslations(); | ||
| const errorDetails = [ |
There was a problem hiding this comment.
Could we not make an array? I think simply rendering:
{error.message}
{error.digest && `digest: ${error.digest}`}Would probably be cleaner...
|
Follow-up on the latest review feedback:\n\n- removed the unnecessary env exposure from apps/site/next.config.mjs\n- simplified the error details rendering in apps/site/app/[locale]/error.tsx so it no longer builds an intermediate array\n\nThe dedicated layouts.error.details key and the hidden-details test coverage from the previous follow-up commits are still in place. |
| /** | ||
| * Public-facing Vercel environment, safe to use in client-side code. | ||
| */ | ||
| export const PUBLIC_VERCEL_ENV = | ||
| process.env.NEXT_PUBLIC_VERCEL_ENV || VERCEL_ENV; | ||
|
|
||
| /** | ||
| * Error details should only be exposed in local development or Vercel preview | ||
| * deployments, never in production. | ||
| */ | ||
| export const SHOW_ERROR_DETAILS = IS_DEV_ENV || PUBLIC_VERCEL_ENV === 'preview'; |
There was a problem hiding this comment.
Do we need this variables, or can we just always show error details?
Fixes #7464
This updates the localized error page so local development and Vercel preview deployments can surface the underlying error details, while production keeps the generic 500 page.
This PR is intentionally small and focused: