fix and update
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { ensureApiGatewayReady } from '@/lib/api';
|
||||
|
||||
const GATEWAY_RETRY_STATUS = new Set([502, 503, 504]);
|
||||
const MEDIA_FETCH_MAX_ATTEMPTS = 8;
|
||||
const MEDIA_SLOW_LOAD_WARN_MS = 8_000;
|
||||
@@ -45,7 +43,6 @@ export async function fetchMediaBlobWithRetry(
|
||||
|
||||
for (let attempt = 0; attempt < MEDIA_FETCH_MAX_ATTEMPTS; attempt += 1) {
|
||||
try {
|
||||
await ensureApiGatewayReady();
|
||||
const response = await fetch(mediaUrl, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
cache: 'no-store'
|
||||
|
||||
Reference in New Issue
Block a user