mirror of
https://github.com/modrinth/code.git
synced 2026-08-27 18:14:49 +00:00
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:
@@ -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),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user