-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat(nextjs): Add section about custom _error.js
to manual setup page
#4286
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/sentry/sentry-docs/GQF6EhjYwqbA7t5CCDzot7hPVpuX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a couple suggestions
Co-authored-by: Isabel <[email protected]>
This adds another file to be copied into the user's project when they run the nextjs version of the wizard, specifically the `_error.js` page which the vercel folks include in their Sentry example app[1] in order to catch more errors. As they say in the comments of that file: ``` // Next.js will pass an err on the server if a page's data fetching methods // threw or returned a Promise that rejected // // Running on the client (browser), Next.js will provide an err if: // // - a page's `getInitialProps` threw or returned a Promise that rejected // - an exception was thrown somewhere in the React lifecycle (render, // componentDidMount, etc) that was caught by Next.js's React Error // Boundary. Read more about what types of exceptions are caught by Error // Boundaries: https://reactjs.org/docs/error-boundaries.html ``` Given that `_error.js` doesn't go at the root level of the project the way the others do, and given that users can either store their page files in `pages` or `src/pages`, I had to add some logic for computing the destination of each copied file. Also, since `_error.js` already starts with an underscore, I felt like adding an underscore to the front of our copy of a file in cases where the file already exists wasn't a great scheme anymore, so I changed to adding `wizardcopy` just before the file's extension (so, for example, if `next.config.js` already exists, we'll now create `next.config.wizardcopy.js`). (This has the added advantage that the real file and our copy now alphabetize right next to one another, so it's dead simple to find them for merging.) This change is added to the manual setup page in docs in getsentry/sentry-docs#4286. [1] https://github.com/vercel/next.js/blob/canary/examples/with-sentry/pages/_error.js
In getsentry/sentry-wizard#140, we update
@sentry/wizard
to include a custom_error.js
page, which is necessary to catch certain errors when an app is deployed to Vercel. (The contents of the page come from Vercel's example Sentry app.) This updates the manual setup docs to reflect this additional step.