Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(nextjs): Don't assert existance of pageProps in _app #5945

Merged
merged 3 commits into from Oct 13, 2022

Conversation

lforst
Copy link
Member

@lforst lforst commented Oct 13, 2022

Even though the Next.js docs tell users to call App.getInitialProps(appContext) in their custom _app pages, many of them don't and this will crash our implementation because the user's getInitialProps will most likely not contain a pageProps property.

This PR adds a simple check if the pageProps are there, and inserts them if they aren't. This should not have any negative consequences.

@lforst lforst added this to the NextJS Improvements milestone Oct 13, 2022
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m: can we test this?

@lforst
Copy link
Member Author

lforst commented Oct 13, 2022

m: can we test this?

It would require us to have an intentionally faulty (more or less global) configuration in our Next.js integration tests. Wdyt?

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on a quick test if possible. Otherwise LGTM

EDIT: Just saw your comment. If you think this is too much hassle, I'm fine with not testing the edge case (logaf low)

@AbhiPrasad
Copy link
Member

It would require us to have an intentionally faulty (more or less global) configuration in our Next.js integration tests.

hmm yeah that’s right, there’s only 1 app set up. Can we somehow edit the app for just a single test? Like send a header via the request sent. Otherwise is it possible we unit test this somehow for regression test purposes?

if it’s too hard np, we can just ship

lforst and others added 2 commits October 13, 2022 10:23
…InitialProps.ts

Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
@lforst lforst enabled auto-merge (squash) October 13, 2022 12:31
@lforst lforst merged commit 960f9a5 into master Oct 13, 2022
@lforst lforst deleted the lforst-defensive-nextjs-app-wrapper branch October 13, 2022 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants