fix(web): give AI spec-suggestion calls a timeout above the AI provider's

request.js's shared axios instance times out every admin call at 10s,
but AI matching settings allow the server to wait up to 600s
(aimatching.maxTimeoutSecs) for a real chat/completions round trip.
For shopee product 49915704844 the size dimension had no deterministic
match and genuinely called the model; the frontend cut the connection
before the server replied, which the browser reports as a generic
network failure ("服务器连接异常") that has nothing to do with the
actual cause. Override the timeout on just these two calls instead of
the shared default, which stays tight for every other (fast) admin
request.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VkjpksKeizaRpYXfgD74Lf
This commit is contained in:
QiuSW
2026-08-31 16:37:04 +08:00
co-authored by Claude Sonnet 5
parent 17c9b7c3b1
commit 5338dd0072
+8 -2
View File
@@ -52,12 +52,18 @@ export function previewShopeeAutoSizeMatches(productId) {
return request({ url: `/api/admin/v1/shopee-products/${productId}/specs/mapping/preview-auto-size`, method: 'post' })
}
// AI 建议会同步等待一次真实的大模型调用,服务端 AI 匹配设置允许的超时最长可达 600
// 秒(aimatching.maxTimeoutSecs)。这里的超时必须明显长于服务端上限,否则前端会先
// 掐断连接,浏览器把这当作连接失败,弹出与真实原因无关的「服务器连接异常」。不改全局
// axios 默认超时,只放宽这两个会触发外部调用的接口。
const aiSuggestTimeoutMs = 610000
export function suggestShopeeColorMappings(productId, data) {
return request({ url: `/api/admin/v1/shopee-products/${productId}/specs/mapping/suggest-colors`, method: 'post', data })
return request({ url: `/api/admin/v1/shopee-products/${productId}/specs/mapping/suggest-colors`, method: 'post', data, timeout: aiSuggestTimeoutMs })
}
export function suggestShopeeSizeMappings(productId, data) {
return request({ url: `/api/admin/v1/shopee-products/${productId}/specs/mapping/suggest-sizes`, method: 'post', data })
return request({ url: `/api/admin/v1/shopee-products/${productId}/specs/mapping/suggest-sizes`, method: 'post', data, timeout: aiSuggestTimeoutMs })
}
export function batchDeleteShopeeProducts(data) {