From 381dd60bea791b0084ded702aa13a8383bbf7034 Mon Sep 17 00:00:00 2001 From: "DESKTOP-JKIE562\\PC" <1013397054@qq.com> Date: Tue, 1 Dec 2026 15:35:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=96=87=E4=BB=B6=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E8=B6=85=E6=97=B6):=E4=BA=A7=E7=89=A9/=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E7=AD=89=E6=96=87=E4=BB=B6=E4=B8=8B=E8=BD=BD=E8=B5=B0=2010=20?= =?UTF-8?q?=E5=88=86=E9=92=9F=E4=BC=A0=E8=BE=93=E9=A2=84=E7=AE=97=EF=BC=88?= =?UTF-8?q?62MB=20=E7=BF=BB=E8=AF=91=E5=B7=A5=E4=BD=9C=E7=B0=BF=2030s=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E8=B6=85=E6=97=B6=E8=A2=AB=E6=8E=90=E6=96=AD?= =?UTF-8?q?=EF=BC=8C=E6=8A=A5=E8=AF=B7=E6=B1=82=E8=B6=85=E6=97=B6=EF=BC=89?= =?UTF-8?q?=EF=BC=9BrequestTimeouts=20=E5=A2=9E=E5=8A=A0=20DOWNLOAD=5FTIME?= =?UTF-8?q?OUT=5FMS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/utils/request.ts | 6 +++++- frontend/src/utils/requestTimeouts.ts | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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