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

The build fails when fetchOptions.cache is set to "no-store" and query function is used in an RSC component. #391

Open
ktmouk opened this issue Nov 23, 2024 · 1 comment

Comments

@ktmouk
Copy link

ktmouk commented Nov 23, 2024

I encountered the "Dynamic server usage" error when fetchOptions.cache was set to no-store and the query function was used in an RSC component. According to the error message, it seems that Next failed to detect that the RSC component depends on API requests during prerendering.

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
ApolloError: Dynamic server usage: Route / couldn't be rendered statically because it used revalidate: 0 fetch https://swapi-graphql.netlify.app/.netlify/functions/index /.
See more info here: https://nextjs.org/docs/messages/dynamic-server-error

As a workaround, I could successfully build by defining export const dynamic = 'force-dynamic'; in the Page component. However, Ideally, I would like to build without any workaround as it would be a more intuitive.

The errors occurred in both Next.js 14 and 15.

Reproduction

https://github.com/ktmouk/apollo-next-no-store

@phryneas
Copy link
Member

This sounds like a Next.js bug - deep down, Apollo Client only makes a fetch request. I'm not sure what we could do here.

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

2 participants