mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 03:55:59 +00:00
fix: generatedstate memory leak & bump ts query
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
"@modrinth/utils": "workspace:*",
|
||||
"@sentry/vue": "^8.27.0",
|
||||
"@sfirew/minecraft-motd-parser": "^1.1.6",
|
||||
"@tanstack/vue-query": "5.90.7",
|
||||
"@tanstack/vue-query": "5.101.4",
|
||||
"@tauri-apps/api": "^2.5.0",
|
||||
"@tauri-apps/plugin-dialog": "^2.2.1",
|
||||
"@tauri-apps/plugin-fs": "^2.4.5",
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
"@modrinth/ui": "workspace:*",
|
||||
"@modrinth/utils": "workspace:*",
|
||||
"@sentry/nuxt": "^10.33.0",
|
||||
"@tanstack/vue-query": "5.90.7",
|
||||
"@tanstack/vue-query": "5.101.4",
|
||||
"@types/three": "^0.172.0",
|
||||
"@vitejs/plugin-vue": "^6.0.3",
|
||||
"@vue-email/components": "^0.0.21",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { ISO3166, Labrinth } from '@modrinth/api-client'
|
||||
import type { DisplayProjectType } from '@modrinth/utils'
|
||||
import type { ShallowRef } from 'vue'
|
||||
|
||||
import {
|
||||
apiUrl,
|
||||
@@ -155,11 +156,23 @@ const generatedState = shallowRef<GeneratedState>(
|
||||
}) as GeneratedState,
|
||||
)
|
||||
|
||||
/**
|
||||
* Non-reactive server-side view of the state above.
|
||||
*
|
||||
* `generatedState` lives for the lifetime of the isolate, so every per-request `computed()` that
|
||||
* reads it registers a subscriber link on its dep. SSR never unmounts, so those links are never
|
||||
* released, and each one pins the whole request graph that created it. The data is frozen and
|
||||
* `setGameVersions` is client-only, so the server has nothing to react to.
|
||||
*/
|
||||
const serverGeneratedState = {
|
||||
value: generatedState.value,
|
||||
} as unknown as ShallowRef<GeneratedState>
|
||||
|
||||
/**
|
||||
* Composable for accessing the globally used generated state.
|
||||
* This includes both fetched data and runtime-defined constants.
|
||||
*/
|
||||
export const useGeneratedState = () => generatedState
|
||||
export const useGeneratedState = () => (import.meta.server ? serverGeneratedState : generatedState)
|
||||
|
||||
/**
|
||||
* Replaces the build-time game versions with a freshly fetched list. Client-only: mutating this
|
||||
|
||||
Reference in New Issue
Block a user