c-hive / dotdev

Next.js SPA professional website template for teams and individuals: https://c-hive.github.io/dotdev/
MIT License
0 stars 1 forks source link

Attempt to fix pre-render errors #137

Closed gomorizsolt closed 4 years ago

gomorizsolt commented 4 years ago

I'm just guessing because the error itself is somewhat vague. Tried to follow their recommendations to find out what the root cause is but to no avail (it's an error that cannot be reproduced locally).

The issue definitely has something to do with: https://github.com/c-hive/dotdev/pull/131/files

My gut feeling is that there's something wrong with that "_app" component though it's identical to their example. Let's remove this and inject the <Head /> component in the root path (mostly because it's a single-page app without different routes with different titles).

thisismydesign commented 4 years ago

What are pre-render errors? Do we have an issue for this?

Did you test this on your fork? Does it solve the issue?

gomorizsolt commented 4 years ago

I should've been a bit more precise regarding where the issue stems from, sorry.

TL;DR

There's nothing to do with this PR. It should be fixed by #138. Let's discuss if needed.

What are pre-render errors? Do we have an issue for this?

The CI fails on master for some reason:

Error occurred prerendering page "/". Read more: https://err.sh/next.js/prerender-error

"Pre-render" is a term which is frequently used in the case of SSGs (it's one of their fundamental reasons why they're so popular). What it basically refers to is generating each page way ahead of time (pages are compiled to static HTML) which results in 1) decreased loading time (because the app can be served from the "edge", be cached etc) 2) better user-experience (there's something to look at while the page is loading). One thing that's important to note here is that even though the pages are static, they're hydrated to become a fully interactive application if needed (e.g. fetch data at client-side when a component mounts).

Resources if you're interested in this topic:

Did you test this on your fork? Does it solve the issue?

Right, it's my bad. I should've tested the changes against my forked repo instead of "guessing".

Turns out, the changes do not fix the error whatsoever:

TypeError: Cannot read property 'name' of null

https://github.com/c-hive/dotdev/blob/d05189401629373bfdf5671ba8285d402e54ea0d/pages/index.js#L11

As we pointed out the other day, the CONFIG secret becomes a single-line string and because there's a leading # in the first line (because I copy-pasted the example config to the environment variable) it's converted to a single-line comment. That's the reason for receiving null when importing the config (hence the error Cannot read property 'name' of null).

gomorizsolt commented 4 years ago

Closed because of https://github.com/c-hive/dotdev/pull/137#issuecomment-631300061.