Repository navigation
Closed
Labels
priority: highHigh priority
Description
Problem Statement
Multiple paginated queries hit Convex's 16MB bytes read limit because they collect ALL documents before slicing for pagination. The error is currently occurring in listExecutionsPaginated but the same pattern exists in other queries.
Error:
Uncaught Error: Too many bytes read in a single function execution (limit: 16777216 bytes)
Affected Queries
| Query | File | Status |
|---|---|---|
listExecutionsPaginated |
convex/model/wf_executions/list_executions_paginated.ts |
Currently failing |
getProducts |
convex/model/products/get_products.ts |
At risk (3510+ products) |
getDocuments |
convex/model/documents/get_documents.ts |
At risk |
All use the same anti-pattern:
const allItems = [];
for await (const item of query) {
allItems.push(item); // Collects ALL items
}
const total = allItems.length;
const paginated = allItems.slice(offset, offset + pageSize);Root Cause
- Offset-based pagination requires knowing total count
- To get total count, queries load ALL matching documents
- Large documents (executions with
variables,workflowConfig, etc.) exceed 16MB limit - Even smaller documents will fail eventually as data grows
Proposed Solution
Switch to cursor-based pagination using Convex's native .paginate() method:
- Uses early termination - stops as soon as
numItems + 1are found - Never reads the entire dataset
- Scales infinitely regardless of total data volume
UI will change from page numbers to infinite scroll ("Load more" pattern).
Affected Components
Phase 1: Fix Executions (Critical - Currently Broken)
-
convex/model/wf_executions/list_executions_paginated.ts- Add cursor-based query -
convex/model/wf_executions/types.ts- Add cursor args interface -
convex/model/wf_executions/validators.ts- Add cursor args validator -
convex/wf_executions.ts- Export new query -
components/ui/data-table/data-table.tsx- Add infinite scroll support -
executions/components/executions-table.tsx- Switch to cursor pagination -
executions/page.tsx- Update preload
Phase 2: Fix Products (Preventive)
-
convex/model/products/get_products.ts- Add cursor-based query -
products/components/product-table.tsx- Switch to cursor pagination
Phase 3: Fix Documents (Preventive)
-
convex/model/documents/get_documents.ts- Add cursor-based query -
documents/components/document-table.tsx- Switch to cursor pagination
Acceptance Criteria
- No 16MB bytes read errors regardless of data volume
- Executions, Products, Documents pages load quickly with large datasets
- Filters continue to work correctly
- Infinite scroll UI allows loading more results
- SSR preloading still works
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
priority: highHigh priority
Activity
larryro commentedon Jan 8, 2026
Implementation Plan
Step 1: Create New Cursor-Based Query Function
File:
convex/model/wf_executions/list_executions_paginated.tsAdd
listExecutionsCursorfunction using the existingpaginateWithFilterhelper for early termination.Step 2: Add New Types and Validators
ListExecutionsCursorArgsinterfacelistExecutionsCursorArgsValidatorStep 3: Export New Query
File:
convex/wf_executions.ts- ExportlistExecutionsCursorqueryStep 4: Add Infinite Scroll to DataTable
File:
components/ui/data-table/data-table.tsx- AddinfiniteScrollpropStep 5: Update Frontend Components
useCursorPaginatedQueryFiles to Modify
convex/model/wf_executions/list_executions_paginated.tsconvex/model/wf_executions/types.tsconvex/model/wf_executions/validators.tsconvex/wf_executions.tscomponents/ui/data-table/data-table.tsxexecutions/components/executions-table.tsxexecutions/page.tsxTesting Strategy
Generated with Claude Code
[-]Fix Convex 16MB bytes read limit in listExecutionsPaginated by switching to cursor-based pagination[/-][+]Fix Convex 16MB bytes read limit by switching all paginated pages to cursor-based pagination[/+]larryro commentedon Jan 8, 2026
Updated Implementation Plan
Phase 1: Shared Infrastructure
infiniteScrollprop toDataTablecomponentPhase 2: Fix Executions (Critical)
listExecutionsCursorfunction usingpaginateWithFilterListExecutionsCursorArgsinterfacelistExecutionsCursorArgsValidatorlistExecutionsCursorqueryexecutions-table.tsxto useuseCursorPaginatedQueryexecutions/page.tsxpreloadPhase 3: Fix Products
getProductsCursorfunction usingpaginateWithFilterGetProductsCursorArgsinterfacegetProductsCursorqueryproduct-table.tsxto useuseCursorPaginatedQueryPhase 4: Fix Documents
getDocumentsCursorfunction usingpaginateWithFilterGetDocumentsCursorArgsinterfacegetDocumentsCursorquerydocument-table.tsxto useuseCursorPaginatedQueryFiles to Modify (14 total)
components/ui/data-table/data-table.tsxinfiniteScrollpropconvex/model/wf_executions/list_executions_paginated.tslistExecutionsCursorconvex/model/wf_executions/types.tsconvex/model/wf_executions/validators.tsconvex/wf_executions.tslistExecutionsCursorexecutions/components/executions-table.tsxexecutions/page.tsxconvex/model/products/get_products.tsgetProductsCursorconvex/model/products/types.tsconvex/products.tsgetProductsCursorproducts/components/product-table.tsxconvex/model/documents/get_documents.tsgetDocumentsCursorconvex/model/documents/types.tsconvex/documents.tsgetDocumentsCursordocuments/components/document-table.tsx🤖 Generated with Claude Code
feat(ui): add infiniteScroll prop to DataTable for cursor-based pagin…
feat(convex): add cursor-based pagination for executions
fix(executions): migrate table to cursor-based pagination
feat(convex): add cursor-based pagination for products
fix(products): migrate table to cursor-based pagination
feat(convex): add cursor-based pagination for documents
fix(documents): migrate table to cursor-based pagination
fix(ui): move load more button inside table border
fix: convert remaining tables to cursor-based pagination