rsnext/examples/with-sentry/pages/404.js

7 lines
170 B
JavaScript
Raw Normal View History

import Error from 'next/error'
export default function NotFound() {
Update with-sentry example to show how to track API routes + bug fixes (#16484) ## New features - Example of how to use `Sentry.captureException()` in API routes https://github.com/vercel/next.js/commit/5a35982717bc7f916022dd713b3b1f9e0921d503 ## Bug fixes - Server-side source maps now work in Sentry when deployed to Vercel https://github.com/vercel/next.js/commit/629a9ed5048629dc12670ef457fe6efaa2e8d3b6 - If uploading source maps, `Sentry.init()` now sets the `release`, so that exceptions are correctly associated with the source maps in that release ## Open issues ### `_error.js` is unused for `getServerSideProps` errors when deployed to Vercel Instead of rendering this example's overridden `_error.js` (like it does when testing locally with `NODE_ENV='production'`), when deployed to Vercel and an Error is thrown from `getServerSideProps`, this page is shown: ![Screenshot of Vercel Application Error page](https://user-images.githubusercontent.com/709153/90968889-aa3c3d00-e4a6-11ea-9eff-fafee3d1ff33.png) This confuses me because the Error is still successfully sent to Sentry, but I would've expected it to be sent by the call to `Sentry.captureException()` in `_error.js`. I'm not sure why it works. ### API test 2 & 3 don't work in the "server" build config They don't work when deployed to Vercel in the "serverless" config either, but that's expected because there aren't any handlers to flush the Sentry queue. I can't figure out why they don't work in the long-lived "server" config.
2020-11-09 19:36:36 +01:00
// Opinionated: do not record an exception in Sentry for 404
return <Error statusCode={404} />
}