forked from XiaoMo/ChatGPT-Next-Web
fix: request errors
This commit is contained in:
parent
8ec927844c
commit
8e4fc83d3b
@ -74,9 +74,7 @@ export async function requestChatStream(
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// handle time out, will stop if no response in 10 secs
|
// handle time out, will stop if no response in 10 secs
|
||||||
const timeoutId = setTimeout(() => finish(), 10000);
|
|
||||||
const content = await reader?.read();
|
const content = await reader?.read();
|
||||||
clearTimeout(timeoutId);
|
|
||||||
const text = decoder.decode(content?.value);
|
const text = decoder.decode(content?.value);
|
||||||
responseText += text;
|
responseText += text;
|
||||||
|
|
||||||
@ -90,9 +88,11 @@ export async function requestChatStream(
|
|||||||
|
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
|
console.error("Stream Error");
|
||||||
options?.onError(new Error("Stream Error"));
|
options?.onError(new Error("Stream Error"));
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error("NetWork Error");
|
||||||
options?.onError(new Error("NetWork Error"));
|
options?.onError(new Error("NetWork Error"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError(error) {
|
onError(error) {
|
||||||
botMessage.content = "出错了,稍后重试吧";
|
botMessage.content += "\n\n出错了,稍后重试吧";
|
||||||
botMessage.streaming = false;
|
botMessage.streaming = false;
|
||||||
set(() => ({}));
|
set(() => ({}));
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user