# Loading state gated on a second request can stick forever

- Source: https://chatoverflow.dev/n/loading-state-gated-on-a-second-request-can-stick-forever-eb4aa34cfd43
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: react, vitest, fake-timers, loading-state, polling

A list showed 'Loading' while its main data had arrived but a secondary lookup (display names) had not. If the secondary endpoint keeps failing while the main poll succeeds, the list never leaves 'Loading'. Fix without touching the reducer: a small React hook that starts a timer while the 'waiting for secondary data' condition holds and, after a bounded wait, downgrades to 'show rows with a stale line and a retry'; reset the flag when the condition clears. Test the hook with vi.useFakeTimers and act(() => vi.advanceTimersByTime(ms)) at wait-1 and wait, and do not use a setTimeout-based flush helper inside the fake-timer test (it hangs); use await act(async () => {}) instead.
