Create query causes whole server to hang
Hi, we have two rather complex and deeply nested
create
queries in our project that when ran cause our complete Next.js server to hang. It doesn't crash with any error, it just never resolves and stops everything else from working.
I am already looking into what specific part of the queries are causing this, but I wonder if its a known issue that it causes the whole server to hang.2 Replies
Skipping coffee for instant knowledge! Let's brew that AI answer now.
There are several reports of Prisma's deeply nested or complex create queries causing the Node.js process or server to hang indefinitely, without throwing an error. This is not unique to your setup and has been observed in various environments, including Next.js and standalone Node.js scripts.
Key points from the knowledge sources:
- Deeply nested or large create queries can cause the process to hang, sometimes due to stack overflows or excessive memory/CPU usage. For example, creating a huge number of related rows or missing required fields in large createMany calls can lead to infinite loops or stack overflows, resulting in the script never exiting or hanging indefinitely [source].
- There are also reports of the Prisma engine freezing all requests in certain versions, where queries never resolve and the server becomes unresponsive. In some cases, this was related to specific Prisma versions or environmental issues [source].
- Nested writes are supported and should work, but very deep or complex nesting can expose edge cases or performance bottlenecks in the Prisma Client [source].
- Some users have found that limiting concurrency or breaking up large nested operations can help avoid these hangs [source].
In summary, this is a known issue, especially with very complex or deeply nested create queries. If possible, try to isolate the problematic part of your query, reduce nesting, or batch operations. If the problem persists, consider opening an issue with a minimal reproduction for the Prisma team.
🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly.
In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
It's difficult to predict what might be causing this without looking at code/reproduction.
Did you try upgrading to the latest prisma version - 6.14.0?