-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
(v3) next.js serverless build run into timeout #1432
Comments
We investigated a bit further. You can now test this without next-on-netlify.
You can see it render the page pretty quickly. But the process never terminates. In React Query v2 this was working fine. Try using:
You can see it render the page and then terminate immediately. |
We traced this down to the GC timeout: https://github.com/tannerlinsley/react-query/blob/ac342e237ae9fab6759f2d7be616662da6c16225/src/core/query.ts#L169 First we added We then realized this might be related to the GC. So we set |
So basically the script does not terminate because the GC timeout is still running in the background? I can imagine this would be pretty hard to track down for most people. Not sure what a good default behavior would be though, as some users also want to use the caching functionality on the server as singleton. Either we need to change this behavior or make it explicit in the docs. |
Yeah. For us a workaround could be to set the const queryClient = new QueryClient({
defaultOptions: {
queries: {
cacheTime: typeof window === "undefined" ? -1 : 5 * 60 * 1000,
},
},
}); I agree with you, though. It would be nice to make this explicit somehow. |
How was this implemented previously? IIRC the |
Previously GC was disabled when running on a server (which means you also couldn't use the functionality). Would running |
I don't know at which point I would have to call If you have control over the server, that could be a good solution. |
Update: setting cacheTime to Reproducable on branch Thinking about this, would you prefer a separate issue for the CancelledError? |
We played with different options:
It seems like running |
Created a fix for the cancelled queries when using low cache times and also removed the cache time hydration. In the meanwhile, you should be able to disable the GC with |
Thanks for fixing this so quickly. We just tested with version 3.3.0. It works for us with the following setup:
Is this worth mentioning in the SSR docs? |
I really would like to get this to a better place that feels more automatic so nothing extra is necessary. @boschni Do you think that's feasible? |
Yeah I guess it's a bit difficult because in some SSR scenarios you want to have GC running, but in case of Lambda deployments you don't. A flag to disable GC could be added though, then at least you don't need to juggle with the cache times? |
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.” |
Any update on this, are planning to add the flag? |
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:
yarn install
yarn run build
yarn run next-on-netlify
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.
The text was updated successfully, but these errors were encountered: