fix: memory leaks — cleanup timers on unmount, tighten speech queue, fix isOwner reactivity

- FightViewer: track deferred speechSynthesis.cancel() timer, clear on unmount
- BotProfilePage: change isOwner from ref to computed for reactive login state
- sounds.ts: tighten speech queue depth cap from 3 to 2

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-07 23:52:11 +00:00
co-authored by Claude Opus 4.6
parent c98007e95c
commit b2d1a2da02
3 changed files with 10 additions and 7 deletions
+6 -1
View File
@@ -46,6 +46,7 @@ const canvasContainer = ref<HTMLElement>()
const logEl = ref<HTMLElement>()
let scene: FightSceneController | null = null
const sceneReady = ref(false)
let cleanupTimerHandle: ReturnType<typeof setTimeout> | null = null
const isReplaying = ref(false)
const displayHpA = ref(100)
@@ -98,6 +99,8 @@ onUnmounted(() => {
stopAllAudio()
sceneReady.value = false
if (scene) { scene.destroy(); scene = null }
if (cleanupTimerHandle) { clearTimeout(cleanupTimerHandle); cleanupTimerHandle = null }
if (typeof speechSynthesis !== 'undefined') speechSynthesis.cancel()
})
async function initScene() {
@@ -398,8 +401,10 @@ async function replay() {
}
// Kill any remaining queued speech — fight is over
setTimeout(() => {
if (cleanupTimerHandle) clearTimeout(cleanupTimerHandle)
cleanupTimerHandle = setTimeout(() => {
if (typeof speechSynthesis !== 'undefined') speechSynthesis.cancel()
cleanupTimerHandle = null
}, 3000)
isReplaying.value = false