fix(文件下载超时):产物/附件等文件下载走 10 分钟传输预算(62MB 翻译工作簿 30s 默认超时被掐断,报请求超时);requestTimeouts 增加 DOWNLOAD_TIMEOUT_MS
deploy-hxtesting / build-and-deploy (push) Successful in 1m15s
deploy-hxtesting / build-and-deploy (push) Successful in 1m15s
This commit is contained in:
1 parent
7034d93256
commit
381dd60bea
2 files changed
+16
-1
No files matched your search
@@ -4,7 +4,7 @@ import { generateRandomString, MAX_FILE_SIZE_MB, MAX_SKILL_BUNDLE_SIZE_MB } from
|
|||||||
import i18n from '@/i18n'
|
import i18n from '@/i18n'
|
||||||
import { getApiBaseUrl } from './api-base';
|
import { getApiBaseUrl } from './api-base';
|
||||||
import { isSkillBundleUploadUrl } from './uploadLimit';
|
import { isSkillBundleUploadUrl } from './uploadLimit';
|
||||||
import { isTimeoutError, uploadTimeoutMs } from './requestTimeouts';
|
import { DOWNLOAD_TIMEOUT_MS, isTimeoutError, uploadTimeoutMs } from './requestTimeouts';
|
||||||
import {
|
import {
|
||||||
forceReloginRedirect,
|
forceReloginRedirect,
|
||||||
isEmbedPage,
|
isEmbedPage,
|
||||||
@@ -237,6 +237,10 @@ export function get<T = any>(url: string, config?: any): Promise<WithStatus<T>>
|
|||||||
export async function getDown(url: string): Promise<Blob> {
|
export async function getDown(url: string): Promise<Blob> {
|
||||||
const res = await instance.get<Blob>(url, {
|
const res = await instance.get<Blob>(url, {
|
||||||
responseType: "blob",
|
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;
|
}) as unknown as Blob;
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,3 +50,14 @@ export function isTimeoutError(error: unknown): boolean {
|
|||||||
if (code === 'ECONNABORTED' || code === 'ETIMEDOUT') return true
|
if (code === 'ECONNABORTED' || code === 'ETIMEDOUT') return true
|
||||||
return typeof message === 'string' && /timeout/i.test(message)
|
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
|
||||||
Reference in new issue
Block a user