Skip to content

Commit 3acf0d4

Browse files
committed
fix for use-activity-query: entry not stale if got errors recently
1 parent 592687b commit 3acf0d4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

cli/src/hooks/use-activity-query.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,20 @@ function getCacheEntry<T>(key: string): CacheEntry<T> | undefined {
114114
export 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

121133
function setQueryFetching(key: string, fetching: boolean): void {

0 commit comments

Comments
 (0)