Is onScopeDispose clientside only?
I cannot for the life of me get it to trigger during SSR. If so, how are you expected to dispose of the active scope in SSR?
3 Replies
Hi @FabiansGeikinsSpeckle. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the provided knowledge sources, there isn't specific information about
onScopeDispose
and its behavior during SSR in Nuxt. The documents don't contain enough details to directly answer your question about whether onScopeDispose
is client-side only or how to dispose of the active scope in SSR.
However, I can provide some general context about client-side and server-side execution in Nuxt:
1. Nuxt uses universal rendering by default, which means some code runs on both server and client sides. However, certain lifecycle hooks and components are specifically designed for client-side execution.
2. Nuxt provides ways to differentiate between server and client environments. For example, the nuxtApp.isHydrating
property can be used to check if the app is hydrating on the client side, as mentioned in the useNuxtApp documentation.
3. For client-only code, Nuxt offers the <ClientOnly>
component and the .client
suffix for components that should only render on the client side, as described in the Client Components documentation.
Given that onScopeDispose
is not specifically mentioned in the provided Nuxt documentation, it's possible that this Vue 3 composition API function might have limitations or behave differently in the SSR context of Nuxt. To get a definitive answer, you might need to consult the Vue 3 documentation or experiment with Nuxt's SSR lifecycle hooks to find an appropriate alternative for scope disposal during SSR.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@950315795802628106> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
I'm actually debugging through what looks like a memory leak of @vue/apollo-composable. They use the active scope to track active operations and then clean up that stuff on scope dispose. Specifically the leak comes from storing EffectScopes in a map, and then not being able to dispose them because of no onScopeDispose.
If the answer is that onScopeDispose is just not meant for SSR, then I will treat this as a bug in the library.