From f31b74f7fd63598d6261693e8fc74c8fe56a395d Mon Sep 17 00:00:00 2001 From: "Calum H." Date: Thu, 30 Oct 2025 19:18:24 +0000 Subject: [PATCH] fix: show hostname on modrinth servers 503 (#4678) * fix: show hostname on modrinth servers 503 * fix: lint --- .../src/composables/servers/servers-fetch.ts | 41 ++++++++++++++++--- .../src/pages/servers/manage/[id].vue | 5 ++- .../servers/errors/modrinth-server-error.ts | 1 + 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/apps/frontend/src/composables/servers/servers-fetch.ts b/apps/frontend/src/composables/servers/servers-fetch.ts index 9b90822ce..c47d4e549 100644 --- a/apps/frontend/src/composables/servers/servers-fetch.ts +++ b/apps/frontend/src/composables/servers/servers-fetch.ts @@ -30,7 +30,7 @@ export async function useServersFetch( '[Modrinth Servers] Cannot fetch without auth', 10000, ) - throw new ModrinthServerError('Missing auth token', 401, error, module) + throw new ModrinthServerError('Missing auth token', 401, error, module, undefined, undefined) } const { @@ -52,7 +52,14 @@ export async function useServersFetch( '[Modrinth Servers] Circuit breaker open - too many recent failures', 503, ) - throw new ModrinthServerError('Service temporarily unavailable', 503, error, module) + throw new ModrinthServerError( + 'Service temporarily unavailable', + 503, + error, + module, + undefined, + undefined, + ) } if (now - lastFailureTime.value > 30000) { @@ -69,7 +76,14 @@ export async function useServersFetch( '[Modrinth Servers] Cannot fetch without base url. Make sure to set a PYRO_BASE_URL in environment variables', 10001, ) - throw new ModrinthServerError('Configuration error: Missing PYRO_BASE_URL', 500, error, module) + throw new ModrinthServerError( + 'Configuration error: Missing PYRO_BASE_URL', + 500, + error, + module, + undefined, + undefined, + ) } const versionString = `v${version}` @@ -179,6 +193,7 @@ export async function useServersFetch( fetchError, module, v1Error, + error.data, ) } @@ -200,6 +215,8 @@ export async function useServersFetch( undefined, fetchError, module, + undefined, + undefined, ) } } @@ -212,7 +229,14 @@ export async function useServersFetch( statusCode, lastError, ) - throw new ModrinthServerError('Maximum retry attempts reached', statusCode, pyroError, module) + throw new ModrinthServerError( + 'Maximum retry attempts reached', + statusCode, + pyroError, + module, + undefined, + lastError.data, + ) } const fetchError = new ModrinthServersFetchError( @@ -220,5 +244,12 @@ export async function useServersFetch( undefined, lastError || undefined, ) - throw new ModrinthServerError('Maximum retry attempts reached', undefined, fetchError, module) + throw new ModrinthServerError( + 'Maximum retry attempts reached', + undefined, + fetchError, + module, + undefined, + undefined, + ) } diff --git a/apps/frontend/src/pages/servers/manage/[id].vue b/apps/frontend/src/pages/servers/manage/[id].vue index 653c9f5c0..5e750616c 100644 --- a/apps/frontend/src/pages/servers/manage/[id].vue +++ b/apps/frontend/src/pages/servers/manage/[id].vue @@ -1043,7 +1043,10 @@ const nodeUnavailableDetails = computed(() => [ }, { label: 'Node', - value: server.general?.datacenter ?? 'Unknown', + value: + server.moduleErrors?.general?.error.responseData?.hostname ?? + server.general?.datacenter ?? + 'Unknown', type: 'inline' as const, }, { diff --git a/packages/utils/servers/errors/modrinth-server-error.ts b/packages/utils/servers/errors/modrinth-server-error.ts index 3551af71e..6c7fe5d8e 100644 --- a/packages/utils/servers/errors/modrinth-server-error.ts +++ b/packages/utils/servers/errors/modrinth-server-error.ts @@ -9,6 +9,7 @@ export class ModrinthServerError extends Error { public readonly originalError?: Error, public readonly module?: string, public readonly v1Error?: V1ErrorInfo, + public readonly responseData?: any, ) { let errorMessage = message let method = 'GET'