fix: remove SSE connection failure notice timer
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1844,8 +1844,6 @@ export function ChatProvider({ children }: { children: ReactNode }) {
|
|||||||
|
|
||||||
let eventSource: EventSource | null = null;
|
let eventSource: EventSource | null = null;
|
||||||
let reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
let reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
let sseNoticeTimer: ReturnType<typeof setTimeout> | null = null;
|
|
||||||
let sseNoticeShown = false;
|
|
||||||
|
|
||||||
const connect = () => {
|
const connect = () => {
|
||||||
if (eventSource) eventSource.close();
|
if (eventSource) eventSource.close();
|
||||||
@@ -1869,12 +1867,6 @@ export function ChatProvider({ children }: { children: ReactNode }) {
|
|||||||
|
|
||||||
connect();
|
connect();
|
||||||
|
|
||||||
sseNoticeTimer = setTimeout(() => {
|
|
||||||
if (cancelled || sseNoticeShown) return;
|
|
||||||
sseNoticeShown = true;
|
|
||||||
addSystemMessageRef.current("无法连接实时事件流,请确认 WebUI 已启动且穿透域名可访问");
|
|
||||||
}, 12_000);
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
window.removeEventListener("resize", onResize);
|
window.removeEventListener("resize", onResize);
|
||||||
@@ -1882,7 +1874,6 @@ export function ChatProvider({ children }: { children: ReactNode }) {
|
|||||||
window.visualViewport?.removeEventListener("scroll", syncViewportHeight);
|
window.visualViewport?.removeEventListener("scroll", syncViewportHeight);
|
||||||
window.removeEventListener("orientationchange", syncViewportHeight);
|
window.removeEventListener("orientationchange", syncViewportHeight);
|
||||||
if (reconnectTimer) clearTimeout(reconnectTimer);
|
if (reconnectTimer) clearTimeout(reconnectTimer);
|
||||||
if (sseNoticeTimer) clearTimeout(sseNoticeTimer);
|
|
||||||
eventSource?.close();
|
eventSource?.close();
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user