From 5da954e800cb31dabed84dde38ad99dcd86236da Mon Sep 17 00:00:00 2001 From: Kristaps Fabians Geikins Date: Thu, 9 Jan 2025 13:56:32 +0200 Subject: [PATCH] fix: memory leak in SSR caused by global tracking --- .../vue-apollo-composable/src/util/loadingTracking.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/vue-apollo-composable/src/util/loadingTracking.ts b/packages/vue-apollo-composable/src/util/loadingTracking.ts index 3abb41ef..d5e2527b 100644 --- a/packages/vue-apollo-composable/src/util/loadingTracking.ts +++ b/packages/vue-apollo-composable/src/util/loadingTracking.ts @@ -27,6 +27,15 @@ export function getCurrentTracking () { } let tracking: LoadingTracking + if (isServer) { + // SSR does not support onScopeDispose, so if we don't skip this, it will leak memory + tracking = { + queries: ref(0), + mutations: ref(0), + subscriptions: ref(0), + } + return { tracking } + } if (!globalTracking.components.has(currentScope)) { // Add per-component tracking