fix and update

This commit is contained in:
lendry
2026-06-30 23:18:53 +03:00
parent 6ee3ffe0a5
commit 4b2ade9354
6 changed files with 17 additions and 41 deletions

View File

@@ -545,9 +545,6 @@ export async function refreshAuthSession(): Promise<RefreshSessionResponse> {
export async function syncFedcmSession(accessToken?: string | null) {
const token = resolveAccessToken(accessToken);
if (typeof window === 'undefined' || !token) return;
if (!isApiGatewayReady()) {
await ensureApiGatewayReady();
}
try {
await apiFetch<{ synced: boolean }>(
'/fedcm/session/sync',
@@ -680,7 +677,7 @@ export function buildSystemSettingPayload(setting: Pick<SystemSetting, 'key' | '
}
const GATEWAY_RETRY_STATUS = new Set([502, 503, 504]);
const GATEWAY_RETRY_ATTEMPTS = 6;
const GATEWAY_RETRY_ATTEMPTS = 4;
const GATEWAY_STABLE_PROBE_INTERVAL_MS = 800;
const GATEWAY_STABLE_MAX_ROUNDS = 8;
const API_MAX_CONCURRENT = 6;
@@ -833,7 +830,7 @@ function gatewayRetryDelay(attempt: number): number {
return 800 + attempt * 700;
}
/** Повтор при кратковременном 502/503/504 (nginx не достучался до api-gateway после перезапуска). */
/** Повтор при кратковременном 502/503/504 без сброса всего UI в bootstrap. */
async function fetchWithGatewayRetry(url: string, init: RequestInit): Promise<Response> {
let lastNetworkError: unknown;
for (let attempt = 0; attempt < GATEWAY_RETRY_ATTEMPTS; attempt++) {
@@ -843,24 +840,14 @@ async function fetchWithGatewayRetry(url: string, init: RequestInit): Promise<Re
markApiGatewayReady();
}
if (GATEWAY_RETRY_STATUS.has(response.status) && attempt + 1 < GATEWAY_RETRY_ATTEMPTS) {
invalidateApiGatewayReady();
try {
await ensureApiGatewayReady(true);
} catch {
await sleep(gatewayRetryDelay(attempt));
}
await sleep(gatewayRetryDelay(attempt));
continue;
}
return response;
} catch (error) {
lastNetworkError = error;
if (attempt + 1 < GATEWAY_RETRY_ATTEMPTS) {
invalidateApiGatewayReady();
try {
await ensureApiGatewayReady(true);
} catch {
await sleep(gatewayRetryDelay(attempt));
}
await sleep(gatewayRetryDelay(attempt));
continue;
}
throw mapFetchError(error);