File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -114,8 +114,20 @@ function getCacheEntry<T>(key: string): CacheEntry<T> | undefined {
114114export function isEntryStale ( key : string , staleTime : number ) : boolean {
115115 const entry = getCacheEntry ( key )
116116 if ( ! entry ) return true
117- if ( entry . dataUpdatedAt === 0 ) return true
118- return staleTime === 0 || Date . now ( ) - entry . dataUpdatedAt > staleTime
117+
118+ // If we have successful data, use its timestamp for staleness
119+ if ( entry . dataUpdatedAt !== 0 ) {
120+ return staleTime === 0 || Date . now ( ) - entry . dataUpdatedAt > staleTime
121+ }
122+
123+ // No successful data - check if we have a recent error
124+ // Use errorUpdatedAt to prevent rapid retries on persistent errors
125+ if ( entry . errorUpdatedAt !== null ) {
126+ return staleTime === 0 || Date . now ( ) - entry . errorUpdatedAt > staleTime
127+ }
128+
129+ // No data and no error timestamp - entry is stale
130+ return true
119131}
120132
121133function setQueryFetching ( key : string , fetching : boolean ) : void {
You can’t perform that action at this time.
0 commit comments