From 4b24da98eacb4d1e53b9d3594b436d212aba000f Mon Sep 17 00:00:00 2001 From: Sheldon Guo Date: Wed, 12 Feb 2025 20:04:55 +0800 Subject: [PATCH] chore(sse): remove console error logging for SSE connection retries (#6205) * fix(sse): improve error logging for SSE connection retries * fix(sse): prevent errors by returning early if response data is undefined --- .../src/client/observables/sse.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/plugins/@nocobase/plugin-notification-in-app-message/src/client/observables/sse.ts b/packages/plugins/@nocobase/plugin-notification-in-app-message/src/client/observables/sse.ts index 17de66ae95..1acda46928 100644 --- a/packages/plugins/@nocobase/plugin-notification-in-app-message/src/client/observables/sse.ts +++ b/packages/plugins/@nocobase/plugin-notification-in-app-message/src/client/observables/sse.ts @@ -53,6 +53,7 @@ export const startMsgSSEStreamWithRetry: () => () => void = () => { responseType: 'stream', adapter: 'fetch', }); + if (!res?.data) return; const stream = res.data; const reader = stream.pipeThrough(new TextDecoderStream()).getReader(); retryTimes = 0; @@ -72,7 +73,7 @@ export const startMsgSSEStreamWithRetry: () => () => void = () => { try { await createMsgSSEConnection(clientId); } catch (error) { - console.error('Error during stream:', error.message); + console.log(`sse connection for clientId ${clientId} failed, retrying...`, error); const nextDelay = retryTimes < 6 ? 1000 * Math.pow(2, retryTimes) : 60000; retryTimes++; setTimeout(() => {