@@ -58,7 +58,10 @@ export function useNotifyDataReady<TData, TError = Error>({
58
58
const forcePollingFF = useFeatureFlag ( 'forceHttpPolling' )
59
59
const seenHostname = useRef < string | null > ( null )
60
60
const [ refetch , setRefetch ] = useState < HTTPRefetchFrequency > ( null )
61
- const [ isNotifyEnabled , setIsNotifyEnabled ] = useState ( true )
61
+ const [
62
+ hasEncounteredNotificationsError ,
63
+ setHasEncounteredNotificationsError ,
64
+ ] = useState ( false )
62
65
63
66
const { enabled, staleTime, forceHttpPolling } = options
64
67
@@ -80,8 +83,6 @@ export function useNotifyDataReady<TData, TError = Error>({
80
83
} )
81
84
dispatch ( notifySubscribeAction ( hostname , topic ) )
82
85
seenHostname . current = hostname
83
- } else {
84
- setIsNotifyEnabled ( false )
85
86
}
86
87
87
88
return ( ) => {
@@ -98,7 +99,7 @@ export function useNotifyDataReady<TData, TError = Error>({
98
99
99
100
const onDataEvent = useCallback ( ( data : NotifyResponseData ) : void => {
100
101
if ( data === 'ECONNFAILED' || data === 'ECONNREFUSED' ) {
101
- setIsNotifyEnabled ( false )
102
+ setHasEncounteredNotificationsError ( true )
102
103
if ( data === 'ECONNREFUSED' ) {
103
104
doTrackEvent ( {
104
105
name : ANALYTICS_NOTIFICATION_PORT_BLOCK_ERROR ,
@@ -120,6 +121,8 @@ export function useNotifyDataReady<TData, TError = Error>({
120
121
[ refetch , options . onSettled ]
121
122
)
122
123
124
+ const isNotifyEnabled =
125
+ shouldUseNotifications && ! hasEncounteredNotificationsError
123
126
const queryOptionsNotify = {
124
127
...options ,
125
128
onSettled : isNotifyEnabled ? notifyOnSettled : options . onSettled ,
0 commit comments