Skip to content

Commit c956170

Browse files
iHiDclaude
andauthored
Only dehydrate successful queries to prevent unhandled rejections (#8608)
The custom shouldDehydrateQuery callback was overriding TanStack Query's default status check, allowing pending queries to be dehydrated. When a pending query's promise later rejected (e.g. network error), the dehydration catch handler would create an unhandled Error("redacted"), which Sentry captured. Add query.state.status === 'success' check to match the default behavior. Closes #8605 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 61d3085 commit c956170

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

app/javascript/packs/application.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,13 @@ if (typeof window !== 'undefined') {
249249
shouldDehydrateQuery: (query) => {
250250
const [key] = query.queryKey
251251
// only persist notifications and reputation in localStorage cache
252-
return [NOTIFICATIONS_CACHE_KEY, REPUTATION_CACHE_KEY].includes(
253-
key as string
252+
// also check status to avoid dehydrating pending queries whose
253+
// promises can reject with an unhandled "redacted" error
254+
return (
255+
query.state.status === 'success' &&
256+
[NOTIFICATIONS_CACHE_KEY, REPUTATION_CACHE_KEY].includes(
257+
key as string
258+
)
254259
)
255260
},
256261
},

0 commit comments

Comments
 (0)