Skip to content

fix(feed): prevent Latest feed from blanking on background refetch#14470

Merged
dylanjeffers merged 1 commit into
mainfrom
fix/latest-feed-empty-on-refetch
Jun 10, 2026
Merged

fix(feed): prevent Latest feed from blanking on background refetch#14470
dylanjeffers merged 1 commit into
mainfrom
fix/latest-feed-empty-on-refetch

Conversation

@dylanjeffers

Copy link
Copy Markdown
Contributor

useFeed was missing staleTime (default 0), so any background refetch returning [] would overwrite a populated feed. Also fixes the enabled override — options.enabled was being silently discarded and currentUserId !== null was firing queries while the account was still loading (undefined), seeding an empty cache entry. Mirrors the fix from 3d65667 applied to useForYouFeed.

Apply the same staleTime + enabled guard fix that was landed in
useForYouFeed (commit 3d65667) to the "Latest" chronological
feed hook, which was left behind.

Bug 1 — missing staleTime:
useFeed had no staleTime, so the react-query default of 0 caused
the query to refetch immediately after the first paint on every
mount/focus. If that refetch settled empty (transient backend
result, or a different validator node in the fleet), react-query
replaced the populated feed with `[]`. The lineup reads an empty
list as "no content" and renders the empty state, causing the feed
to flash and then blank. Fix: staleTime: 5 * 60 * 1000 (5 min,
overridable via options). Infinity is used for the For You feed
because those results are personalised and session-stable; 5 min
is used here because the Latest feed is chronological and users
reasonably expect fresh content when they return after a while.

Bug 2 — enabled logic override / undefined account:
The hook spread ...options after the enabled field, so any
options.enabled: false passed by a caller was silently discarded.
Worse, the check used !== null (strict), so while the account is
still resolving and currentUserId is undefined the query fired,
ran the !currentUserId guard inside queryFn, and returned [],
caching that empty result under the [feed, undefined] key. A
later render could briefly read that key and flash the empty state.
Fix: move enabled after ...options with the same guard used in
useForYouFeed (options?.enabled !== false && currentUserId != null).

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d2ab2b9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

🌐 Web preview ready

Preview URL: https://audius-web-preview-pr-14470.audius.workers.dev

Unique preview for this PR (deployed from this branch).
Workflow run

@dylanjeffers dylanjeffers merged commit 906cf14 into main Jun 10, 2026
13 checks passed
@dylanjeffers dylanjeffers deleted the fix/latest-feed-empty-on-refetch branch June 10, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant