Skip to content

Commit bcda35a

Browse files
claudeOpenClaw Assistant
authored andcommitted
Fix getChallengeFeed "multiple paginated queries" error
Replace .collect() calls with bounded .take() reads inside the paginated getChallengeFeed query. Convex only allows a single paginated query per function execution; .collect() on larger result sets can internally trigger paginated reads, conflicting with the explicit .paginate() call on the activities table. Changes: - follows query: .collect() → .take(1000) - likes count per activity: .collect() → .take(500) - comments count per activity: .collect() → .take(500) Fixes Sentry #7280439142 https://claude.ai/code/session_01Q598Pr5xHFqAS7PAU1GCNA
1 parent 41fe44b commit bcda35a

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

packages/backend/queries/activities.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export const getChallengeFeed = query({
173173
const follows = await ctx.db
174174
.query("follows")
175175
.withIndex("followerId", (q) => q.eq("followerId", currentUser._id))
176-
.collect();
176+
.take(1000);
177177
followingIds = new Set(follows.map((f) => f.followingId));
178178

179179
if (authDebugEnabled) {
@@ -256,12 +256,12 @@ export const getChallengeFeed = query({
256256
ctx.db
257257
.query("likes")
258258
.withIndex("activityId", (q) => q.eq("activityId", activity._id))
259-
.collect()
259+
.take(500)
260260
.then((likes) => likes.length),
261261
ctx.db
262262
.query("comments")
263263
.withIndex("activityId", (q) => q.eq("activityId", activity._id))
264-
.collect()
264+
.take(500)
265265
.then((comments) => comments.length),
266266
])
267267
: [0, 0];
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Fix Activity Feed Pagination Error
2+
3+
**Date:** 2026-03-01
4+
**Issue:** Sentry error #7280439142`getChallengeFeed` throws "multiple paginated queries" error
5+
6+
## Problem
7+
8+
The `getChallengeFeed` query uses Convex's built-in `.paginate()` for the main activity feed, but also calls `.collect()` within the hydration loop to count likes and comments per activity. Convex only allows a single paginated query per function execution; `.collect()` on larger result sets can internally trigger paginated reads, conflicting with the explicit `.paginate()` call.
9+
10+
**Error:** `Uncaught Error: This query or mutation function ran multiple paginated queries. Convex only supports a single paginated query in each function.`
11+
12+
**Stack:** `handler in ../../queries/activities.ts [Line 229]`
13+
14+
## Fix
15+
16+
- [x] Replace `.collect()` calls with bounded `.take()` reads for likes and comments counting inside the paginated hydration loop
17+
- [x] Replace `.collect()` on the follows query with `.take()` to be defensive
18+
- [x] Verify typecheck and lint pass
19+
20+
## Notes
21+
22+
- `.take(n)` avoids the internal pagination mechanism that `.collect()` can trigger for larger result sets
23+
- The limits chosen (1000 for follows, 500 for likes/comments) are generous for real-world usage and stay within Convex's per-function document read limits

0 commit comments

Comments
 (0)