Fix server ping race condition before protocol version is available (#6935)

* fix race condition with server ping lookup before protocol resolved

* fix refresh button on worlds page
This commit is contained in:
Prospector
2026-08-03 07:00:54 +00:00
committed by GitHub
parent ae13d37edc
commit 779edf0333
3 changed files with 62 additions and 11 deletions
+11 -5
View File
@@ -435,11 +435,12 @@ export async function refreshServerData(
}
}
export function refreshServers(
export async function refreshServers(
worlds: World[],
serverData: Record<string, ServerData>,
protocolVersion: ProtocolVersion | null,
) {
ping = true,
): Promise<void> {
const servers = worlds.filter(isServerWorld)
servers.forEach((server) => {
if (!serverData[server.address]) {
@@ -451,9 +452,14 @@ export function refreshServers(
}
})
// noinspection ES6MissingAwait - handled by refreshServerData
Object.keys(serverData).forEach((address) =>
refreshServerData(serverData[address], protocolVersion, address),
if (!ping) {
return
}
await Promise.all(
Object.keys(serverData).map((address) =>
refreshServerData(serverData[address], protocolVersion, address),
),
)
}