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 🙏maximum call stack exceeded - Drizzle Team
Weird bug where whenever I add a
where
eq
clause getting maximum call stack exceededRangeError: Maximum call stack size exceeded - When I try to INSERT...
Hi,
I am getting
RangeError: Maximum call stack size exceeded
when I try to INSERT something in the DB, SELECT queries works with no issues.
I am using "drizzle-orm": "^0.25.3"
and "@remix-run/react": "^1.15.0"
.
I have a page to add an organization with the following action:
```typescript
export const action = async ({ request, context ...GitHub
RangeError: Maximum call stack size exceeded
on incorrect `prisma...Bug description Calls to prisma.<model>.createMany are behaving unexpectedly when provided a sufficient number of records that are missing a required field. For ~20k records, the call seems t...
1 Reply
I think at the very least, a more informative error message should be given when this happens.
Also if the reason is understood and unavoidable maybe a warning with inserts of more than a certain size would be useful.
Maybe a utility from Drizzle to break inserted data into chunks, I use this: