From 8e4fc83d3bf58496e5ed791aa5b9f548f79c7dfd Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Tue, 14 Mar 2023 00:34:52 +0800 Subject: [PATCH] fix: request errors --- app/requests.ts | 4 ++-- app/store.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/requests.ts b/app/requests.ts index 4e1ca0573..54c09e8d6 100644 --- a/app/requests.ts +++ b/app/requests.ts @@ -74,9 +74,7 @@ export async function requestChatStream( while (true) { // handle time out, will stop if no response in 10 secs - const timeoutId = setTimeout(() => finish(), 10000); const content = await reader?.read(); - clearTimeout(timeoutId); const text = decoder.decode(content?.value); responseText += text; @@ -90,9 +88,11 @@ export async function requestChatStream( finish(); } else { + console.error("Stream Error"); options?.onError(new Error("Stream Error")); } } catch (err) { + console.error("NetWork Error"); options?.onError(new Error("NetWork Error")); } } diff --git a/app/store.ts b/app/store.ts index baf35df88..d0e38b004 100644 --- a/app/store.ts +++ b/app/store.ts @@ -229,7 +229,7 @@ export const useChatStore = create()( } }, onError(error) { - botMessage.content = "出错了,稍后重试吧"; + botMessage.content += "\n\n出错了,稍后重试吧"; botMessage.streaming = false; set(() => ({})); },