From ba8f36502232ff20b61b3e5448ec0f513e6b18c1 Mon Sep 17 00:00:00 2001 From: hobby Date: Fri, 7 Mar 2025 00:13:30 +0800 Subject: [PATCH] fix time out issue --- src/components/ChatUI.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/ChatUI.tsx b/src/components/ChatUI.tsx index 6d68413..82fc0cd 100644 --- a/src/components/ChatUI.tsx +++ b/src/components/ChatUI.tsx @@ -289,7 +289,7 @@ const ChatUI = () => { while (true) { //console.log("读取中") const startTime = Date.now(); - const { done, value } = await Promise.race([ + let { done, value } = await Promise.race([ reader.read(), new Promise((_, reject) => setTimeout(() => reject(new Error('响应超时')), timeout - (Date.now() - startTime)) @@ -298,8 +298,11 @@ const ChatUI = () => { if (Date.now() - startTime > timeout) { reader.cancel(); - - throw new Error('响应超时'); + console.log("读取超时") + if (completeResponse.trim() === "") { + throw new Error('响应超时'); + } + done = true; } if (done) {