Hotfix: fix /skills count fallback runtime on Convex#376
Conversation
PR SummaryMedium Risk Overview Tightens Written by Cursor Bugbot for commit 94380d9. This will update automatically on new commits. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 94380d9724
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const skills = await ctx.db | ||
| .query('skills') | ||
| .withIndex('by_active_updated', (q) => q.eq('softDeletedAt', undefined)) | ||
| .collect() |
There was a problem hiding this comment.
Avoid full-table collect in public-skill count fallback
When skills.countPublicSkills falls back to countPublicSkillsForGlobalStats (e.g. missing globalStats row/storage), this now loads every active skill in a single .collect() call, which can exceed Convex query result limits for larger datasets and throw instead of returning a count. The repo already treats this as a real constraint for aggregate scans (convex/skills.ts notes using paginated action flow to avoid the 16MB limit), so this fallback can still break /skills in production precisely during cold-start/recovery scenarios.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| .query('skills') | ||
| .withIndex('by_active_updated', (q) => q.eq('softDeletedAt', undefined)) | ||
| .order('asc') | ||
| .paginate({ cursor, numItems: GLOBAL_STATS_PAGE_SIZE }) |
There was a problem hiding this comment.
Collect risks hitting Convex document read limit
Medium Severity
countPublicSkillsForGlobalStats now uses .collect() to load all matching skills into memory. Convex enforces a hard per-function document read limit of 16,384. The current dataset has 7,774 skills — roughly half the cap. When the skills table grows past ~16K non-deleted rows, this will throw a TooManyDocumentsRead error. This affects the countPublicSkills query fallback, adjustGlobalPublicSkillsCount initialization, and the updateGlobalStatsInternal cron job.


Follow-up hotfix after re-landing #76.
Issue
skills.countPublicSkillsfallback used repeated paginated queries, which Convex disallows inside one function.Fix
collect()query inconvex/lib/globalStats.ts.toPublicSkill.convex/_generated/api.d.ts.Verification
bun run lintbun run testbunx convex deploy -ybunx convex run --deployment-name wry-manatee-359 statsMaintenance:updateGlobalStatsInternalbunx convex run --deployment-name wry-manatee-359 skills:countPublicSkills(returned7774)