Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions examples/with-sentry/pages/_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,23 @@ MyError.getInitialProps = async ({ res, err, asPath }) => {

if (err) {
Sentry.captureException(err)
} else {
// If this point is reached, getInitialProps was called without any
// information about what the error might be. This is unexpected and may
// indicate a bug introduced in Next.js, so record it in Sentry
Sentry.captureException(
new Error(`_error.js getInitialProps missing data at path: ${asPath}`)
)
}

try {
// Flushing before returning is necessary if deploying to Vercel, see
// https://vercel.com/docs/platform/limits#streaming-responses
await Sentry.flush(2000)

return errorInitialProps
} catch (err) {
// no-empty
}

// If this point is reached, getInitialProps was called without any
// information about what the error might be. This is unexpected and may
// indicate a bug introduced in Next.js, so record it in Sentry
Sentry.captureException(
new Error(`_error.js getInitialProps missing data at path: ${asPath}`)
)
await Sentry.flush(2000)

return errorInitialProps
}

Expand Down
11 changes: 8 additions & 3 deletions examples/with-sentry/pages/api/test4.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ async function handler(req, res) {
throw new Error('API Test 4')
} catch (error) {
Sentry.captureException(error)

try {
// Flushing before returning is necessary if deploying to Vercel, see
// https://vercel.com/docs/platform/limits#streaming-responses
await Sentry.flush(2000)
} catch (err) {
// no-empty
}
}

// Flushing before returning is necessary if deploying to Vercel, see
// https://vercel.com/docs/platform/limits#streaming-responses
await Sentry.flush(2000)
res.status(200).json({ name: 'John Doe' })
}

Expand Down
10 changes: 7 additions & 3 deletions examples/with-sentry/pages/ssr/test4.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ export async function getServerSideProps() {
} catch (error) {
Sentry.captureException(error)

// Flushing before returning is necessary if deploying to Vercel, see
// https://vercel.com/docs/platform/limits#streaming-responses
await Sentry.flush(2000)
try {
// Flushing before returning is necessary if deploying to Vercel, see
// https://vercel.com/docs/platform/limits#streaming-responses
await Sentry.flush(2000)
} catch (err) {
// no-empty
}
}

return { props: {} }
Expand Down