zach_e_s
zach_e_s
DTDrizzle Team
Created by zach_e_s on 5/31/2024 in #help
Large inserts throw `RangeError: Maximum call stack size exceeded`
In several cases I've noticed that with inserts of ~4k rows I get this RangeError: Maximum call stack size exceeded error. Note that I am using .onDuplicateKeyUpdate (i.e. they are upserts). By breaking my inserted data into chunks of ~2k rows each, I can do inserts without this bug. This suggests to me that my application code is not at fault. I'm using Planetscale/MySQL, but I don't think it has to do with the database connection - even using const query = db.insert(...).values(...) and then console.log(query.toSQL()), which normally works, gives the same error when there are this many rows. My guess is that the SQL builder is the culprit (maybe some O(n^2) recursion somewhere). Here are other instances where Drizzle users got this error: - https://www.answeroverflow.com/m/1092908217983578184 - https://www.answeroverflow.com/m/1103370708672851978 - and here is a similar issue from another library (Prisma with createMany) for good measure: https://github.com/prisma/prisma/issues/9196 Any response greatly appreciated. Thanks 🙏
2 replies