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:
Any response greatly appreciated. Thanks 🙏
Weird bug where whenever I add a where eq clause getting maximum call stack exceeded
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
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...
Was this page helpful?