-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sentry): catch
getServerSideProps
errors
Catches and reports `getServerSideProps` errors to sentry explicitly. This is an attempt to workaround a potential bug in Sentry: getsentry/sentry-javascript#7602
- Loading branch information
1 parent
960372b
commit 5ca8a50
Showing
5 changed files
with
86 additions
and
61 deletions.
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,41 +1,43 @@ | ||
import { DEFAULT_STORE_CODE } from '@config/env'; | ||
import { flags } from '@config/flags'; | ||
import { withSentry } from '@helpers/next-helpers'; | ||
import { ifixitOriginFromHost } from '@helpers/path-helpers'; | ||
import { getLayoutServerSideProps } from '@layouts/default/server'; | ||
import { findPage } from '@models/page/server'; | ||
import { GetServerSideProps } from 'next'; | ||
import { PageTemplateProps } from './hooks/usePageTemplateProps'; | ||
|
||
export const getServerSideProps: GetServerSideProps<PageTemplateProps> = async ( | ||
context | ||
) => { | ||
if (!flags.STORE_HOME_PAGE_ENABLED) { | ||
return { | ||
notFound: true, | ||
}; | ||
} | ||
const withMiddleware = withSentry<PageTemplateProps>; | ||
|
||
const layoutProps = await getLayoutServerSideProps({ | ||
storeCode: DEFAULT_STORE_CODE, | ||
}); | ||
const page = await findPage({ | ||
path: '/Store', | ||
}); | ||
export const getServerSideProps: GetServerSideProps<PageTemplateProps> = | ||
withMiddleware(async (context) => { | ||
if (!flags.STORE_HOME_PAGE_ENABLED) { | ||
return { | ||
notFound: true, | ||
}; | ||
} | ||
|
||
const layoutProps = await getLayoutServerSideProps({ | ||
storeCode: DEFAULT_STORE_CODE, | ||
}); | ||
const page = await findPage({ | ||
path: '/Store', | ||
}); | ||
|
||
if (page == null) { | ||
if (page == null) { | ||
return { | ||
notFound: true, | ||
}; | ||
} | ||
|
||
const pageProps: PageTemplateProps = { | ||
layoutProps, | ||
appProps: { | ||
ifixitOrigin: ifixitOriginFromHost(context), | ||
}, | ||
page, | ||
}; | ||
return { | ||
notFound: true, | ||
props: pageProps, | ||
}; | ||
} | ||
|
||
const pageProps: PageTemplateProps = { | ||
layoutProps, | ||
appProps: { | ||
ifixitOrigin: ifixitOriginFromHost(context), | ||
}, | ||
page, | ||
}; | ||
return { | ||
props: pageProps, | ||
}; | ||
}; | ||
}); |
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
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