meowcat.32M
Convex Community11mo ago
2 replies
meowcat.32

Filter size limit

const documents = posts.slice(0, 50);
console.log(JSON.stringify(documents).length); // 37472
await client.mutation(api.tasks.upsertPost, { documents });

export const upsertPost = mutation({
  args: { documents: v.array(schema.tables.posts.validator) },
  handler: async (ctx, { documents }) => {
    await Promise.all(
      documents.map(async (doc) => {
        const existing = await ctx.db
          .query('posts')
          .filter((q) => q.eq(q.field('id'), doc.id))
          .first();
        if (existing) {
          return ctx.db.replace(existing._id, doc);
        } else {
          return ctx.db.insert('posts', doc);
        }
      })
    );
  }
});

[CONVEX M(tasks:upsertPost)] [Request ID: 557f3142a6cb7f0b] Server Error
Uncaught Error: Too many bytes read in a single function execution (limit: 8388608 bytes). Consider using smaller limits in your queries, paginating your queries, or using indexed queries with a selective index range expressions.
    at async <anonymous> (../convex/tasks.ts:13:15)
    at async Promise.all (index 0)all [as all] (<anonymous>)
    at async handler (../convex/tasks.ts:7:18)

why am i getting that error, its not even 50kb 😦
Was this page helpful?