From 5338dd007250d6957a6ace6e5a322f4437dea86f Mon Sep 17 00:00:00 2001 From: QiuSW <105186638@qq.com> Date: Mon, 31 Aug 2026 16:37:04 +0800 Subject: [PATCH] fix(web): give AI spec-suggestion calls a timeout above the AI provider's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Claude-Session: https://claude.ai/code/session_01VkjpksKeizaRpYXfgD74Lf --- web/src/api/goauto/shopee-products.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/src/api/goauto/shopee-products.js b/web/src/api/goauto/shopee-products.js index 0b28cbf..e15f207 100644 --- a/web/src/api/goauto/shopee-products.js +++ b/web/src/api/goauto/shopee-products.js @@ -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) {