From 7fb6401613a464f5e476c4c8239492d8e54bfe15 Mon Sep 17 00:00:00 2001 From: Truman Gao <106889354+tdgao@users.noreply.github.com> Date: Wed, 31 Dec 2025 03:04:14 -0800 Subject: [PATCH] fix: server ping spam (#4983) * add a throttle on populate jump back in list * Revert "add a throttle on populate jump back in list" This reverts commit b3e7f51b34936dd7487a51f2dab7170af19706cf. * only allow populate jump back in list to run 3x on linux * add temp debug logs * Revert "add temp debug logs" This reverts commit 8c5ec42fa3b48f11a416555ae7b366e44fa42b54. * only allow 3x refresh limit for worlds list as well --- .../src/components/ui/world/RecentWorldsList.vue | 11 +++++++++++ apps/app-frontend/src/pages/instance/Worlds.vue | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue b/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue index 2802b866c..4f715f2d0 100644 --- a/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue +++ b/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue @@ -2,6 +2,7 @@ import { LoaderCircleIcon } from '@modrinth/assets' import type { GameVersion } from '@modrinth/ui' import { GAME_MODES, HeadingLink, injectNotificationManager } from '@modrinth/ui' +import { platform } from '@tauri-apps/plugin-os' import type { Dayjs } from 'dayjs' import dayjs from 'dayjs' import { computed, onMounted, onUnmounted, ref, watch } from 'vue' @@ -48,6 +49,11 @@ const gameVersions = ref(await get_game_versions().catch(() => [] const MIN_JUMP_BACK_IN = 3 const MAX_JUMP_BACK_IN = 6 const TWO_WEEKS_AGO = dayjs().subtract(14, 'day') +const MAX_LINUX_POPULATES = 3 + +// Track populate calls on Linux to prevent server ping spam +const isLinux = platform() === 'linux' +const linuxPopulateCount = ref(0) type BaseJumpBackInItem = { last_played: Dayjs @@ -82,6 +88,10 @@ populateJumpBackIn() }) async function populateJumpBackIn() { + // On Linux, limit automatic populates to prevent server ping spam + if (isLinux && linuxPopulateCount.value >= MAX_LINUX_POPULATES) return + if (isLinux) linuxPopulateCount.value++ + console.info('Repopulating jump back in...') const worldItems: WorldJumpBackInItem[] = [] @@ -230,6 +240,7 @@ const checkProcesses = async () => { onMounted(() => { checkProcesses() + linuxPopulateCount.value = 0 }) onUnmounted(() => { diff --git a/apps/app-frontend/src/pages/instance/Worlds.vue b/apps/app-frontend/src/pages/instance/Worlds.vue index 944e80c21..c52bdf7ff 100644 --- a/apps/app-frontend/src/pages/instance/Worlds.vue +++ b/apps/app-frontend/src/pages/instance/Worlds.vue @@ -134,6 +134,7 @@ import { RadialHeader, } from '@modrinth/ui' import type { Version } from '@modrinth/utils' +import { platform } from '@tauri-apps/plugin-os' import { computed, onUnmounted, ref, watch } from 'vue' import { useRoute } from 'vue-router' @@ -214,6 +215,11 @@ const worldPlaying = ref() const worlds = ref([]) const serverData = ref>({}) +// Track servers_updated calls on Linux to prevent server ping spam +const MAX_LINUX_REFRESHES = 3 +const isLinux = platform() === 'linux' +const linuxRefreshCount = ref(0) + const protocolVersion = ref( await get_profile_protocol_version(instance.value.path), ) @@ -224,6 +230,9 @@ const unlistenProfile = await profile_listener(async (e: ProfileEvent) => { console.info(`Handling profile event '${e.event}' for profile: ${e.profile_path_id}`) if (e.event === 'servers_updated') { + if (isLinux && linuxRefreshCount.value >= MAX_LINUX_REFRESHES) return + if (isLinux) linuxRefreshCount.value++ + await refreshAllWorlds() }