How Not To Use TanStack Query - Dan Neciu
summary
A product built entirely on TanStack Query overloads the backend: spikes hit 1,400 requests per second and DB CPU reaches 100%, costing thousands. The team fires mutations that call invalidateQueries repeatedly, producing tens of extra refetches (examples: 66 → 11 after queuing) and retries after aborted slow requests amplify load. Changing mutations to return the full gamification state and using setQueryData removes many refetches (16 → 0), while turning off default retries on abort causing extra load limits repeat traffic.
AI-written summary · about
chapters (15)
- 0:00Introduction
- 1:05Why TanStack Query
- 2:10From Context to Query
- 3:13Gamification Overuse
- 5:20Invalidation Spiral
- 6:42Performance Crisis
- 8:05Root Cause Analysis
- 9:28Queue Optimization
- 10:10Race Conditions
- 10:52Retry Misconceptions
- 11:34Optimistic Updates
- 12:35Stale Time Myth
- 13:18Cache Time Confusion
- 13:40Query Key Hierarchy
- 14:01Final Advice
