fix: show hostname on modrinth servers 503 (#4678)

* fix: show hostname on modrinth servers 503

* fix: lint
This commit is contained in:
Calum H.
2025-10-30 19:18:24 +00:00
committed by GitHub
parent bcc36362be
commit f31b74f7fd
3 changed files with 41 additions and 6 deletions

View File

@@ -30,7 +30,7 @@ export async function useServersFetch<T>(
'[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<T>(
'[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<T>(
'[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<T>(
fetchError,
module,
v1Error,
error.data,
)
}
@@ -200,6 +215,8 @@ export async function useServersFetch<T>(
undefined,
fetchError,
module,
undefined,
undefined,
)
}
}
@@ -212,7 +229,14 @@ export async function useServersFetch<T>(
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<T>(
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,
)
}

View File

@@ -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,
},
{

View File

@@ -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'