From eb9385840f6768fd585b8d6c0a7a784c81c1d536 Mon Sep 17 00:00:00 2001 From: sawhil Date: Tue, 1 Apr 2025 01:24:59 +0530 Subject: [PATCH] fix: minor error handler message --- .../src/container/LiveLogs/LiveLogsContainer/index.tsx | 8 ++------ frontend/src/providers/EventSource.tsx | 10 ++++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/frontend/src/container/LiveLogs/LiveLogsContainer/index.tsx b/frontend/src/container/LiveLogs/LiveLogsContainer/index.tsx index 85b8d2d476..71be4ee326 100644 --- a/frontend/src/container/LiveLogs/LiveLogsContainer/index.tsx +++ b/frontend/src/container/LiveLogs/LiveLogsContainer/index.tsx @@ -10,7 +10,6 @@ import { useGetCompositeQueryParam } from 'hooks/queryBuilder/useGetCompositeQue import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder'; import useDebouncedFn from 'hooks/useDebouncedFunction'; import { useEventSourceEvent } from 'hooks/useEventSourceEvent'; -import { useNotifications } from 'hooks/useNotifications'; import { prepareQueryRangePayload } from 'lib/dashboard/prepareQueryRangePayload'; import { useEventSource } from 'providers/EventSource'; import { useCallback, useEffect, useRef, useState } from 'react'; @@ -38,8 +37,6 @@ function LiveLogsContainer(): JSX.Element { const batchedEventsRef = useRef([]); - const { notifications } = useNotifications(); - const { selectedTime: globalSelectedTime } = useSelector< AppState, GlobalReducer @@ -88,8 +85,8 @@ function LiveLogsContainer(): JSX.Element { ); const handleError = useCallback(() => { - notifications.error({ message: 'Sorry, something went wrong' }); - }, [notifications]); + console.error('Sorry, something went wrong'); + }, []); useEventSourceEvent('message', handleGetLiveLogs); useEventSourceEvent('error', handleError); @@ -157,7 +154,6 @@ function LiveLogsContainer(): JSX.Element { useEffect((): (() => void) | undefined => { if (isConnectionError && reconnectDueToError && compositeQuery) { - console.log('uncaught refetch try from component', reconnectDueToError); // Small delay to prevent immediate reconnection attempts const reconnectTimer = setTimeout(() => { handleStartNewConnection(compositeQuery); diff --git a/frontend/src/providers/EventSource.tsx b/frontend/src/providers/EventSource.tsx index e75226a424..fa8f1fd223 100644 --- a/frontend/src/providers/EventSource.tsx +++ b/frontend/src/providers/EventSource.tsx @@ -7,6 +7,7 @@ import { ENVIRONMENT } from 'constants/env'; import { LIVE_TAIL_HEARTBEAT_TIMEOUT } from 'constants/liveTail'; import { LOCALSTORAGE } from 'constants/localStorage'; import { EventListener, EventSourcePolyfill } from 'event-source-polyfill'; +import { useNotifications } from 'hooks/useNotifications'; import { createContext, PropsWithChildren, @@ -58,6 +59,8 @@ export function EventSourceProvider({ const eventSourceRef = useRef(null); + const { notifications } = useNotifications(); + const handleSetInitialLoading = useCallback((value: boolean) => { setInitialLoading(value); }, []); @@ -78,8 +81,6 @@ export function EventSourceProvider({ refreshToken: getLocalStorageApi(LOCALSTORAGE.REFRESH_AUTH_TOKEN) || '', }); - console.log('uncaught token refresh started', { response }); - if (response.statusCode === 200) { // Update tokens in local storage afterLogin( @@ -96,8 +97,8 @@ export function EventSourceProvider({ return; } + notifications.error({ message: 'Sorry, something went wrong' }); // If token refresh failed, logout the user - if (!eventSourceRef.current) return; eventSourceRef.current.close(); setIsConnectionError(true); @@ -105,13 +106,14 @@ export function EventSourceProvider({ } catch (error) { // If there was an error during token refresh, we'll just // let the component handle the error state + notifications.error({ message: 'Sorry, something went wrong' }); console.error('Error refreshing token:', error); setIsConnectionError(true); if (!eventSourceRef.current) return; eventSourceRef.current.close(); Logout(); } - }, []); + }, [notifications]); const destroyEventSourceSession = useCallback(() => { if (!eventSourceRef.current) return;