We passed the limit in the feedgen call, but since they are not guaranteed to honor it, we were subject to hydrating a large number of posts if the feedgen didn't respect pagination. We were applying the limit again in the presentation, but hydration had already happened at that point.
Now we apply the limit + some margin right after fetching from the feedgen. The margin is added because some posts might be removed during filtering, so we should usually still have enough to fill a page even after filtering.
If the feed gen misbehaves (returning way more posts than the limit) and filtering doesn't remove enough of them, our pages will be larger than the limit. I figure it is better to return the page with more items in this case to keep the last result in sync with the cursor returned.
I wanted to add a test for this but it felt a bit complicated to do rn.
We passed the limit in the feedgen call, but since they are not guaranteed to honor it, we were subject to hydrating a large number of posts if the feedgen didn't respect pagination. We were applying the limit again in the presentation, but hydration had already happened at that point.
Now we apply the limit + some margin right after fetching from the feedgen. The margin is added because some posts might be removed during filtering, so we should usually still have enough to fill a page even after filtering.
If the feed gen misbehaves (returning way more posts than the limit) and filtering doesn't remove enough of them, our pages will be larger than the limit. I figure it is better to return the page with more items in this case to keep the last result in sync with the cursor returned.
I wanted to add a test for this but it felt a bit complicated to do rn.