query: (v3) next.js serverless build run into timeout

Describe the bug When building a next.js application with a serverless target and deploying it on netlify using next-on-netlify results into the page not rendering and running into a timeout. This problem seems to be related to v3, using v2 the app works as intended.

To Reproduce

Demo: https://react-query-v3-timeout.netlify.app/ Code: https://github.com/frigus02/test-react-query-prefetch-ssr

Steps to reproduce the behavior:

  1. yarn install
  2. yarn run build
  3. yarn run next-on-netlify
  4. yarn run netlify deploy -s <your_site_id> -d out_publish -f out_functions --prod

Expected behavior

It should render the page correctly without running into a timeout.

Additional context

The timeout issue usually results from a promise or some other long running task not finishing. The serverless functions are deployed on a lambda and only return data if the function returns.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

That could be nice. And easily documented. “If you are in a long running server, do nothing. If you are in a short lived server, do this.”

Thanks for fixing this so quickly. We just tested with version 3.3.0. It works for us with the following setup:

  • cacheTime: Infinity for the temporary QueryClient inside getInitialProps/getServerSideProps
  • cacheTime: typeof window === "undefined" ? 0 : 5 * 60 * 1000 for the QueryClient used with the <QueryClientProvider/>

Is this worth mentioning in the SSR docs?