diff --git a/frontend/src/utils/request.ts b/frontend/src/utils/request.ts index 44b18ff..f9b00bf 100644 --- a/frontend/src/utils/request.ts +++ b/frontend/src/utils/request.ts @@ -4,7 +4,7 @@ import { generateRandomString, MAX_FILE_SIZE_MB, MAX_SKILL_BUNDLE_SIZE_MB } from import i18n from '@/i18n' import { getApiBaseUrl } from './api-base'; import { isSkillBundleUploadUrl } from './uploadLimit'; -import { isTimeoutError, uploadTimeoutMs } from './requestTimeouts'; +import { DOWNLOAD_TIMEOUT_MS, isTimeoutError, uploadTimeoutMs } from './requestTimeouts'; import { forceReloginRedirect, isEmbedPage, @@ -237,6 +237,10 @@ export function get(url: string, config?: any): Promise> export async function getDown(url: string): Promise { const res = await instance.get(url, { responseType: "blob", + // File downloads are bounded by payload transfer time (62MB translated + // workbooks are routine), not by the 30s JSON default — which aborts + // them mid-transfer and surfaces as "请求超时". + timeout: DOWNLOAD_TIMEOUT_MS, }) as unknown as Blob; return res } diff --git a/frontend/src/utils/requestTimeouts.ts b/frontend/src/utils/requestTimeouts.ts index 8e82c93..51bed3b 100644 --- a/frontend/src/utils/requestTimeouts.ts +++ b/frontend/src/utils/requestTimeouts.ts @@ -50,3 +50,14 @@ export function isTimeoutError(error: unknown): boolean { if (code === 'ECONNABORTED' || code === 'ETIMEDOUT') return true return typeof message === 'string' && /timeout/i.test(message) } + +/** + * Timeout budget for file downloads (artifacts, attachments, exports). + * + * Downloads are payload-transfer dominated exactly like uploads: a 62MB + * translated workbook takes ~25s to serve on the LAN and far longer on slow + * links, which the 30s JSON default aborts mid-transfer. Fixed 10-minute + * ceiling — it only matters when a transfer stalls; over-generous budgets + * cost nothing on healthy links. + */ +export const DOWNLOAD_TIMEOUT_MS = 10 * 60 * 1000