Menu

The same item shows up twice in the feed, and another one never shows up. Pagination bugs in infinite scroll.
📰

The same item shows up twice in the feed, and another one never shows up. Pagination bugs in infinite scroll.

DEV Community: ios·MinPin Proxy·8 days ago
#Kconlgky
#devtoios#devto#dev#items#cursor
Long article (730 words) — no AI summary yet.
Reading 0:00
15s threshold

The bug reports: "I saw the same post twice while scrolling." "A message I know exists never appeared in the list." Both are hard to reproduce, because they only happen when the data changes while someone is scrolling. In production that's all the time.

Usually the cause is the pagination scheme, not the list view. Here's how it goes wrong and what to use instead.

Offset pagination shifts under you

The classic API: GET /items?offset=40&limit=20 , sorted newest first.

A new item is added at the top between page 2 and page 3. Everything moves down by one. The item that was at position 39 is now at 40, so page 3 starts with an item the user has already seen. Duplicate.

An item is deleted above the current position. Everything moves up by one. The item that was at 40 is now at 39, it falls between page 2 and page 3, and the user never sees it. Missing item.

The client did nothing wrong.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.