Stack overflow when trying to insert many values at once

I'm using drizzle with nextjs so the code is chunked into separate bundles by nextjs it seems, but there are mentions of SQL in the stacktrace and i'm not using any ORM other than drizzle in my project. Here's my code:
await db.insert(table).values(largeListOfValues)
await db.insert(table).values(largeListOfValues)
where largeListOfValues.length is around 30000-40000 entries 5 columns each. And the error:
RangeError: Maximum call stack size exceeded
at /app/.next/server/chunks/662.js:7:27038
at g.buildQueryFromSourceParams (/app/.next/server/chunks/662.js:7:27141)
at /app/.next/server/chunks/662.js:7:26566
at Object.startActiveSpan (/app/.next/server/chunks/662.js:7:32523)
at g.toQuery (/app/.next/server/chunks/662.js:7:26516)
at C.sqlToQuery (/app/.next/server/chunks/662.js:7:7089)
at /app/.next/server/chunks/662.js:1:45521
at Object.startActiveSpan (/app/.next/server/chunks/662.js:7:32523)
at QueryPromise._prepare (/app/.next/server/chunks/662.js:1:45439)
at /app/.next/server/chunks/662.js:1:45671
RangeError: Maximum call stack size exceeded
at /app/.next/server/chunks/662.js:7:27038
at g.buildQueryFromSourceParams (/app/.next/server/chunks/662.js:7:27141)
at /app/.next/server/chunks/662.js:7:26566
at Object.startActiveSpan (/app/.next/server/chunks/662.js:7:32523)
at g.toQuery (/app/.next/server/chunks/662.js:7:26516)
at C.sqlToQuery (/app/.next/server/chunks/662.js:7:7089)
at /app/.next/server/chunks/662.js:1:45521
at Object.startActiveSpan (/app/.next/server/chunks/662.js:7:32523)
at QueryPromise._prepare (/app/.next/server/chunks/662.js:1:45439)
at /app/.next/server/chunks/662.js:1:45671
3 Replies
GamerZero
GamerZeroOP•5mo ago
I've worked around it for now by splitting my list and inserting batches of 1000. But the stack overflow issue is real and I've posted it on github.
GamerZero
GamerZeroOP•5mo ago
GitHub
[BUG]: Stack overflow when trying to insert many values at once · I...
What version of drizzle-orm are you using? 0.31.4 What version of drizzle-kit are you using? 0.22.8 Describe the Bug I'm using drizzle with nextjs so the code is chunked into separate bundles b...
rphlmr âš¡
rphlmr ⚡•5mo ago
Thanks for the bug report. 30000-40000 seems like a lot though. Not sure if the driver can handle such big queries in one batch 👀
Want results from more Discord servers?
Add your server