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

A failed fetch should not break the build #16

Open
YetAnotherJonWilson opened this issue Nov 19, 2023 · 0 comments
Open

A failed fetch should not break the build #16

YetAnotherJonWilson opened this issue Nov 19, 2023 · 0 comments

Comments

@YetAnotherJonWilson
Copy link
Collaborator

In the newer version of Nextjs that we are using, components are server components by default, so fetching is done at build time by default. We are fetching our list of resources from a pod (onboarding.solidcommunity.net), and this is causing a problem when solidcommunity.net goes down, because the failed fetch breaks the build, meaning that we can't deploy any new code changes while the pod is unreachable. It also blocks development, since the fetch is called every time the page refreshes when using npm run dev.

We could put the fetch in a try catch block, and return a hardcoded list of resources when the fetch fails, but that would mean that when we make updates to the code, if the fetch fails, we will revert back to a (possibly older and out of sync) list of resources.

We need to do something like this: cache (or otherwise store?) the most recent successful pod response, and if the fetch fails, use the most recent one instead. I'm not sure if this needs to be done using Github's actions workflow (in the yml file?)--in which case we'd need a separate solution for preventing this from blocking development (a try catch block delivering static results when in dev env would probably be fine)--or in our frontend code. Not sure if Nextjs provides a solution--the new server components use fetch's default cache behavior, which is similar to the deprecated getStaticProps, but that doesn't (as far as I can tell) resolve the problem when the fetch fails at build time.

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

No branches or pull requests

1 participant