Skip to content

Commit

Permalink
[Examples] Fix with-sentry (vercel#15694)
Browse files Browse the repository at this point in the history
  • Loading branch information
lfades authored Jul 30, 2020
1 parent dcb69ee commit 73303a7
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions examples/with-sentry/pages/_error.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import NextErrorComponent from 'next/error'
import * as Sentry from '@sentry/node'

const MyError = async ({ statusCode, hasGetInitialPropsRun, err }) => {
const MyError = ({ statusCode, hasGetInitialPropsRun, err }) => {
if (!hasGetInitialPropsRun && err) {
// getInitialProps is not called in case of
// https://github.com/vercel/next.js/issues/8592. As a workaround, we pass
// err via _app.js so it can be captured
Sentry.captureException(err)
// flush is needed after calling captureException to send server side errors to Sentry, otherwise the serverless function will exit before it's sent
await Sentry.flush(2000)
}

return <NextErrorComponent statusCode={statusCode} />
Expand Down

0 comments on commit 73303a7

Please sign in to comment.