This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Explicitly capture getServerSideProps
exceptions
#1504
Closed
masonmcelvain
wants to merge
9
commits into
main
from
explicitly-capture-serverside-props-exceptions
Closed
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5b11e77
chore(deps): upgrade sentry to `7.45.0`
masonmcelvain 960372b
fix(sentry): update _error page
masonmcelvain 5ca8a50
fix(sentry): catch `getServerSideProps` errors
masonmcelvain 572ad9a
debug: try `wrapGetServerSidePropsWithSentry`
masonmcelvain 6053587
WIP
danielbeardsley 601bb19
Add logging
danielbeardsley 8b6529b
style: apply prettier formatting diff
github-actions[bot] 3e10ee7
debug(sentry): listen to `unhandledRejection`
masonmcelvain c505731
debug(sentry): prevent duplicate event listeners
masonmcelvain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import { wrapGetServerSidePropsWithSentry } from '@sentry/nextjs'; | ||
import { withSentry } from '@helpers/next-helpers'; | ||
import { GetServerSideProps } from 'next'; | ||
|
||
const MyComponent = () => { | ||
return <h1>Hello World!</h1>; | ||
}; | ||
|
||
export const getServerSideProps: GetServerSideProps = | ||
wrapGetServerSidePropsWithSentry(async (context) => { | ||
export const getServerSideProps: GetServerSideProps = withSentry( | ||
async (context) => { | ||
if (context.query.myParam === 'two') { | ||
// only throw conditionally so that this page actually builds | ||
Promise.reject(new Error("We don't like page two")); | ||
} | ||
|
||
return { props: {} }; | ||
}, '/myPage'); | ||
} | ||
); | ||
|
||
export default MyComponent; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think we shouldn't be doing this inside the
withSentry()
call. Otherwise, if you usewithSentry()
more than once it will subscribe multiple times. Vercel is kinda special in that they only run one next.js page per process, but not every environment is like that.I think we should do it at the module level (
sentry.client.config
andsentry.server.config
)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.
Ah yea good call. This implementation didn't report to Sentry, nor did I see the logs, but I will try it in the config file.
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.
Womp womp still no dice when registered in
sentry.server.config