fix: reconnect while disconnect only while error

This commit is contained in:
Tristan Yang
2022-10-25 11:40:41 +08:00
parent 82cdd6a66d
commit 0560170484
3 changed files with 21 additions and 11 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "vocechat-web",
"version": "0.3.12",
"version": "0.3.14",
"private": true,
"homepage": "https://voce.chat",
"dependencies": {
+8 -8
View File
@@ -20,14 +20,14 @@ let prices = [
export const LicensePriceList =
process.env.NODE_ENV === "development"
? [
...prices,
{
title: "VoceChat Enterprise",
limit: 99999,
pid: "price_1LkQGpGGoUDRyc3jGTh3GYHw",
desc: "test price"
}
]
...prices,
{
title: "VoceChat Enterprise",
limit: 99999,
pid: "price_1LkQGpGGoUDRyc3jGTh3GYHw",
desc: "test price"
}
]
: prices;
export const PAYMENT_URL_PREFIX =
process.env.NODE_ENV === "production"
+12 -2
View File
@@ -82,9 +82,19 @@ export default function useStreaming() {
initialized = true;
};
SSE.onerror = (err) => {
console.error("sse error", err);
const { readyState } = err.target as EventSource;
console.error("sse error", readyState);
// 连接还处于开启或正在连接状态
if (readyState === EventSource.OPEN || readyState === EventSource.CONNECTING) {
return;
}
initializing = false;
// 正常的关闭
if (readyState === EventSource.CLOSED) {
initialized = false;
return;
}
// 非正常状态,目前未知
stopStreaming();
if (inter) {
clearTimeout(inter);