Repository navigation
fix: treat a feed refresh with no stories as failed - #289
Merged
Merged
Conversation
therealsama
force-pushed
the
fix/empty-feed-refresh-loop
branch
from
October 5, 2026 19:31
1257386 to
dced13b
Compare
Opening a feed from its cache refreshes it, and the swipe viewer and the desktop list call loadMore for as long as the feed counts as cached. The page fetchers drop every story whose read fails, so when all the reads fail the page request still succeeds, with no stories. That refresh left the feed marked as cached, so loadMore kept fetching the next page. On Top, where each page after the first is an older day, the new e2e tests saw the swipe viewer make 364 day requests in three seconds, the whole year, and the desktop list up to 54. A refresh that brings no stories back now fails like any other failed request: the cached stories stay, the error stops the eager loadMore calls, and the automatic retry asks for the front page again.
therealsama
force-pushed
the
fix/empty-feed-refresh-loop
branch
from
October 6, 2026 08:55
dced13b to
79af10d
Compare
therealsama
enabled auto-merge
October 6, 2026 09:24
kplachkov
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a feed refresh came back with no stories, the feed stayed marked as cached, and the swipe viewer and desktop list paged through every older day. This happens on
main. It came up while reviewing #288, which didn't cause it. This branch is rebased ontomainwith #288 merged.The bug
Opening a feed from its cache refreshes it in the background. Until the refresh lands, the feed counts as cached (
isFromCache), andSwipeStoryViewerandStoryListcallloadMorewhenever that's set and nothing is loading or failed. The page fetchers (fetchTopStories,fetchBestStories,fetchNewStories,fetchRankedStories) drop each story whose Firebase read fails, so when every read fails the request still succeeds, with an empty page. The feed stayed marked as cached, eachloadMorefetched the next page, and on Top, where every page after the first is an older day, the viewer went through the whole year. In a Playwright run at phone size, with a mock that returns three stories a day, that was 364 day requests and 1,097 panels in under three seconds, in both Chromium and WebKit.The trigger is rare: every story read has to fail or come back empty while the list of ids still loads, as in a Firebase outage or a permissions error. I haven't seen it happen against the live API.
The fix
useInfiniteStoriesnow throws when a refresh's page is empty, for Top, Best/New and Ask/Show. That goes through the existing error path. The cached stories stay on screen, the error stops the eagerloadMorecalls (both check!error), anduseAutoRetryretries after 2, 4 and 8 s. A retry is still a refresh, so it asks for the front page again, not an older day. An empty page after the first one still just adds nothing, as before. #288's check that a refresh's page isn't empty before it keeps the reader's stories can't fail any more, so it's removed.The visible change: if the retries also come back empty, the reader sees the cached stories and the usual error with a retry button, where before they got a year of older days.
One case the retries can't fix: Best, New, Ask and Show keep their list of ids in memory for 5 minutes, even when it's empty. If Firebase returns an empty or missing list, the retries reuse it and fail again, and a manual retry works only after those 5 minutes. Top reads its list on every attempt, and failing story reads are retried on every feed. I haven't seen Firebase return an empty list, so the fetchers are left as they are.
Testing
npm run typecheck,npm run lintandnpm run test:runpass (1095 tests, 4 new).npm run e2e: 896 passed, 44 skipped (chromium, firefox, Mobile Safari, Mobile Chrome), with retries off.main.mobile-swipe.spec.ts, all four browsers) and the desktop list (story-browsing.spec.ts, chromium and firefox) make no day requests in 3 s and keep the cached stories. They passed 30/30 (5 runs each). Withmain's hook all 6 failed, both before and after fix: keep the story on screen in the swipe viewer, load past Algolia's 1,000-result cap, and two smaller fixes #288 merged: the viewer made 147 to 364 day requests and the desktop list 20 to 55.