You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Address critical Suspense lifecycle bugs from code review
Fixed two critical bugs identified in senior-level code review:
1. **Error after success bug**: Previously threw errors to Error Boundary
even after initial success. Now only throws during initial load.
After first success, errors surface as stale data (matches TanStack
Query behavior).
2. **Promise lifecycle bug**: When deps changed, could throw old promise
from previous collection. Now properly resets promise when collection
changes.
Implementation:
- Track current collection reference to detect changes
- Track hasBeenReady state to distinguish initial vs post-success errors
- Reset promise and ready state when collection/deps change
- Only throw errors during initial load (!hasBeenReadyRef.current)
Tests added:
- Verify NO re-suspension on live updates after initial load
- Verify suspension only on deps change, not on re-renders
This aligns with TanStack Query's Suspense semantics:
- Block once during initial load
- Stream updates after success without re-suspending
- Show stale data if errors occur post-success
Credit: Fixes identified by external code review
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
0 commit comments