Skip to content

Commit e19954b

Browse files
authored
fix(stats): prevent timers from starting after unmount (#10272)
1 parent 4d92a2c commit e19954b

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎dashboard/src/views/stats/StatsPage.vue‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ const themePalette = computed(() => {
361361
let refreshTimer: number | null = null
362362
let uptimeTimer: number | null = null
363363
let copyFeedbackTimer: number | null = null
364+
let isUnmounted = false
364365
365366
function formatNumber(value: number): string {
366367
return new Intl.NumberFormat(locale.value).format(value)
@@ -712,6 +713,8 @@ watch(selectedRange, async () => {
712713
713714
onMounted(async () => {
714715
await refreshStats()
716+
// The initial request may settle after this component has unmounted.
717+
if (isUnmounted) return
715718
refreshTimer = window.setInterval(() => {
716719
void refreshStats()
717720
}, 60_000)
@@ -721,6 +724,7 @@ onMounted(async () => {
721724
})
722725
723726
onBeforeUnmount(() => {
727+
isUnmounted = true
724728
if (refreshTimer !== null) {
725729
window.clearInterval(refreshTimer)
726730
}

0 commit comments

Comments
 (0)