Closed jcmakesense closed 3 years ago
Hey @jcmakesense
I am not aware of any incompatibility leading to memory leaks... I'll keep my eye open to see if I can spot similar behaviour, but that will probably be hard to reproduce.
If you happen to be able to pinpoint which module leads to the memory leak or create a minimal example on codesandbox where the memory leak happens I could do further investigations.
One question though: You are analyzing the browsers (client) memory but taking about a server crash - are you sure the browsers memory accumulating is leading to a server crash? That seems a bit weird to me. Do you mean that the browser crashes?
If so - can you also share how your nuxt app is configured?
br, Pascal
I am experiencing a memory leak as well, haven't used 6.1.1 myself, using 7.1.1. @lupas I think @jcmakesense is inspecting the node process using chrome, I am seeing the same increase in memory usage as requests come and go.
The leak does cause nuxt to crash on the server side. At the moment I am only using the auth module, let me know if I can provide more details.
this is exactly that @BobbieGoed, I inspect the node process from chrome via --inspect at the time of the start server.
I have the same behavior with the auth / firestore and storage modules enabled.
impossible for me to migrate for the moment the server crash regularly with this new version.
I created an empty project using
It looks like memory usage keeps going up when either a mutation or action is set in the services.auth.initialize object. The following is enough to make the memory increase with each request.
services: {
auth: {
initialize: {
onAuthStateChangedMutation: "ON_AUTH_STATE_CHANGED_MUTATION"
}
}
}
When just using auth: true
there is no memory issue. Seems like the issue is related to vuex?
By setting subscribeManually: true
and using a client side plugin to subscribe I am not experiencing the issue. Maybe this workaround could work for you as well @jcmakesense?
Note that the issue persists if plugin mode is unset or set to "server".
// nuxt.config.js
plugins: [{ src: "~/plugins/authSubscribe.js", mode: "client" }],
// authSubscribe.js
export default async context => {
context.$fireAuthStore.subscribe();
};
Hey guys
Thank you all for the investigations so far - this is indeed an issue in the module that needs to be be addressed.
In the auth-plugin setup by this module we setup an onAuthStateChanged
listener that listens for the auth state to change. This should only be done on client side. However it seems like we do this also on the server side since v7.0.0 - which creates a new listener for every new page visit -> memory leak.
@BobbieGoede Your subscribe mode "client" solution pointed straight towards the issue, thanks for the tip!
Will find a way to fix it asap and let you know - good catch guys.
Version
@nuxtjs/firebase: 7.1.1 firebase: 8.1.1 nuxt: 2.14.9
Hi !
I tried to update the module but I have a memory leak problem as soon as I switch to 7.1.1 that I don't have by staying in 6.1.1.
Steps to reproduce
Package.json
What is actually happening?
With each new nuxt request, the memory does not seem to be emptied, which gradually leads to a server crash.
For example memory profile after 30 requests :![Image of Yaktocat](https://cdn.jobs.makesense.org/misc/1606919183962ki7i6xr0.png)
Do you have any idea of ββan incompatibility with another module?
Thank you for everything ! JC