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

SSR and CMS question #1712

Closed
nealalpert opened this issue Apr 13, 2017 · 1 comment
Closed

SSR and CMS question #1712

nealalpert opened this issue Apr 13, 2017 · 1 comment
Labels
please add a complete reproduction Please add a complete reproduction.

Comments

@nealalpert
Copy link

When loading content from a CMS in getInitialProps we seem to be getting some erratic errors with server side rendering that imply the data was never returned despite using async/await on our calls to the CMS and returning the data. These errors don't seem to stop the site from rendering

TypeError: Cannot read property 'fullTitle' of undefined
at Default (/website/.next/dist/layouts/Default.js:53:174)
at ReactCompositeComponentWrapper._constructComponentWithoutOwner (/website/node_modules/react-dom/lib/ReactCompositeComponent.j
s:309:14)
at ReactCompositeComponentWrapper._constructComponent (/website/node_modules/react-dom/lib/ReactCompositeComponent.js:285:19)
at ReactCompositeComponentWrapper.mountComponent (/website/node_modules/react-dom/lib/ReactCompositeComponent.js:188:21)
at Object.mountComponent (/website/node_modules/react-dom/lib/ReactReconciler.js:46:35)
at ReactCompositeComponentWrapper.performInitialMount (/website/node_modules/react-dom/lib/ReactCompositeComponent.js:371:34)
at ReactCompositeComponentWrapper.mountComponent (/website/node_modules/react-dom/lib/ReactCompositeComponent.js:258:21)
at Object.mountComponent (/website/node_modules/react-dom/lib/ReactReconciler.js:46:35)
at ReactCompositeComponentWrapper.performInitialMount (/website/node_modules/react-dom/lib/ReactCompositeComponent.js:371:34)
at ReactCompositeComponentWrapper.mountComponent (/website/node_modules/react-dom/lib/ReactCompositeComponent.js:258:21)

In this case fullTitle is a property that a class is expecting to be in the return from getInitialProps.

There are some other issues (#827) that were opened that dealt with this by returning an empty object from getInitialProps if the CMS return any data but that results in errors further down the line of the render chain for us as the properties that are expected to be in the getInitialProps return do not exist.

The errors are inconsistent enough that I'm not sure how to recreate them without changing code enough to break rendering all together. Does anyone have any recommendations on how to tackle this or approach debugging this?

@arunoda
Copy link
Contributor

arunoda commented Apr 13, 2017

So it seems like your fetch request doesn't send data always or something like this.
And make sure, we only support getInitialProps in the page component only.

You must return an object from getInitialProps and now we show a nice error if not.
Also run the latest release of Next.js.

Unfortunately, without a way to re-produce, we can't really help you.
Feel free to re-open when you have a way to isolate the issue.

@arunoda arunoda closed this as completed Apr 13, 2017
@arunoda arunoda added the please add a complete reproduction Please add a complete reproduction. label Apr 13, 2017
@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
please add a complete reproduction Please add a complete reproduction.
Projects
None yet
Development

No branches or pull requests

2 participants