-
Notifications
You must be signed in to change notification settings - Fork 197
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
Memory leak with Smart Query #231
Comments
I'll try to invest on this, but I'm not pretty sure what i can do :( Have you try with I don't know if it belong to If you know how to fix this issue, feel free to make a PR. |
I haven't tried because the problem occurs when i'm in a ssr-environment (tested w/ Nuxt).. Is the node-server that goes out-of-memory. |
I use a lot of smart query in my nuxt app. It's not in production stage but we are in pre-release and I can see memory leak in the digital ocean graphs: Also, There is something strange. It's seem smart query are called two times in SSR and one more in front. If I do that:
In the terminal and the devtools console, each one show two logs (devtools with Edit: I forked @LuXDAmore codesandbox here: https://codesandbox.io/s/nuxt-apollo-smart-query-bug-7p7ni |
@atinux Can you help me with this? I think this is happen to another package as well algolia/vue-instantsearch#685 |
It's "funny" because it's another one issue opened by me 😄 However, if these can help, i've tried to remove cache from Apollo, by setting:
and
and
I did a lot of tests, but I couldn't find a solution. IDK: Maybe, this behavior could be related to this too? nuxt-community/apollo-module#251
|
@manniL Can you help us with this? Or do you have some advice for us? |
@ManUtopiK in that chart, that dips after mem fill up is app crash and restart or just gc ? |
Does this happen only with Nuxt or also within a vue-cli project? |
@aldarund What's do you mean by gc? |
In dev mode, memory leaks are unavoidable due to various issues. These are usually not present in prod! |
I have the same issue in Production. Visiting pages causes memory to continue to grow without stopping. |
As @pimlie already asked: Does that happen with the vue-cli project + it's apollo service too? |
I'm only using the I've not got any projects with |
Not sure if this helps, but based on my latest debugging and testing, I think the memory leak is within/related to the Apollo Provider and how the Apollo Client instances are created and not tearing down after each request. I say this because within my Nuxt project, if I create my own Apollo Client instance in a Vue component (nothing to do with SSR) and make a call to GraphQL endpoint, the request works as expected and everything seems fine. I destroy my instance at the end: My custom ApolloClient class:
I call it like so:
Thats my current workaround to prevent our production server (Heroku with 8 Dyno's) from running out of memory every few hours. Our Nuxt web app isn't that big but gets a lot of traffic so any help to get these memory leaks fixed would be grateful. |
I found this problem both in 'production' and in 'development'. I don't know if it's related, but i've also encountered that using a query in a middle-ware, and passing it down to the asyncData by having: // middle-ware.js
export default async context => {
const { app: { apolloProvider: { defaultClient: apollo }, } = context;
const { data } = await apollo.query(...);
context.KEY = data;
} // page.vue
<template>
<p v-text="KEY" />
</template>
<script>
export default {
asyncData({ KEY }) {
return { KEY };
},
};
</script> cause the HTML of the page to grow up.. I've opened an ISSUE here.. Example:
Using |
Does someone has a runnable minimal reproduction so I can take a look? |
@Akryum Great job! Thanks. |
@Akryum you are the man 👍 |
I've just updated to latest version of this package. Currently running tests. |
@Akryum - Thanks so much! I've watched our production graphs today and can confirm this has removed the sawtooth pattern we'd been seeing before, where memory would ramp up and then we'd restart the app. Much appreciated 👍 |
This seems to still be happening in 4.0.1-rc.1 and rc5 (as well as 4.0.0-rc17-19) |
Version
v4.0.0-rc.7
Reproduction link
https://codesandbox.io/s/nuxt-apollo-smart-query-bug-v585k
Steps to reproduce
What is expected ?
The GarbageCollector can free up the memory after every page reload.
What is actually happening?
Visiting pages with Smart query cause the memory to continue to grow up without stopping.
After ~ 15000 urls (depends on how much HTML there is in page) the server is out of memory.
Additional comments?
Using apolloProvider.defaultClient.query in asyncData it's ok.
There's a library installed in the demo to bulk-test urls, 'npm run siege'. With that it's possible to see the memory growing up.
The text was updated successfully, but these errors were encountered: