Prisma generate fails on big schema file
See original GitHub issueBug description
Hello, my team has found some problems when using prisma generate in our project. When we run npx prisma generate
the client responds with an error when stringifying a JSON object, but we can’t see much in the error stack.
We tried running prisma generate in the original version of the project (prisma 2.26.0) and with the latest version (3.10.0 at the day of publishing this issue)
Output when running with version 2.26.0 and DEBUG=“*”:
Environment variables loaded from .env
prisma : 2.26.0
@prisma/client : 2.26.0
Current platform : windows
C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify>dotenv npx prisma generate
prisma:loadEnv project root found at C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\package.json +0ms
prisma:tryLoadEnv Environment variables loaded from C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\.env +0ms
[dotenv][DEBUG] "DEBUG" is already defined in `process.env` and will not be overwritten
Environment variables loaded from .env
prisma:engines using NAPI: false +0ms
prisma:engines binaries to download query-engine, migration-engine, introspection-engine, prisma-fmt +0ms
Prisma schema loaded from prisma\schema.prisma
prisma:getConfig Using Query Engine Binary at: C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\prisma\query-engine-windows.exe +0ms
prisma:getDMMF Using Query Engine Binary at: C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\prisma\query-engine-windows.exe +0ms
prisma:generator baseDir C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\prisma +0ms
prisma:generator prismaClientDir C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\@prisma\client +1ms
prisma:GeneratorProcess 2022-03-09T13:09:52.904Z prisma:client:generator requiredEngine: queryEngine +0ms
prisma:getGenerators neededVersions {
"9b816b3aa13cc270074f172f30d6eda8a8ce867d": {
"engines": [
"queryEngine"
],
"binaryTargets": []
}
} +0ms
prisma:getGenerators {
prisma:getGenerators generatorBinaryPaths: {
prisma:getGenerators queryEngine: {
prisma:getGenerators windows: 'C:\\Users\\Admin\\Desktop\\Proyectos\\tests\\test-prisma-stringify\\node_modules\\prisma\\query-engine-windows.exe'
prisma:getGenerators }
prisma:getGenerators }
prisma:getGenerators } +180ms
prisma:GeneratorProcess 2022-03-09T13:10:02.791Z prisma:loadEnv skipping package.json at C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\.prisma\package.json +10s
prisma:GeneratorProcess 2022-03-09T13:10:02.792Z prisma:loadEnv skipping package.json at C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\package.json +0ms
prisma:GeneratorProcess 2022-03-09T13:10:02.793Z prisma:loadEnv project root found at C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\package.json +1ms
prisma:tryLoadEnv Environment variables loaded from C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\.env +0ms
[dotenv][DEBUG] "DEBUG" is already defined in `process.env` and will not be overwritten
Error: Error:
RangeError: Invalid string length
at JSON.stringify (<anonymous>)
at respond (C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\@prisma\client\generator-build\index.js:45985:24)
at LineStream.<anonymous> (C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\@prisma\client\generator-build\index.js:45931:11)
at _Generate.parse (C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\prisma\build\index.js:65473:17)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async main (C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\prisma\build\index.js:110797:18)
Output running with version 3.10.0 with DEBUG=“*”:
prisma:engines binaries to download libquery-engine, migration-engine, introspection-engine, prisma-fmt +0ms
prisma:loadEnv project root found at C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\package.json +0ms
prisma:tryLoadEnv Environment variables loaded from C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\.env +0ms
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
prisma:getConfig Using CLI Query Engine (Node-API Library) at: C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\prisma\query_engine-windows.dll.node +0ms
prisma:getDMMF Using CLI Query Engine (Node-API) at: C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\prisma\query_engine-windows.dll.node +0ms
prisma:generator prismaCLIDir C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\prisma +0ms
prisma:generator prismaClientDir C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\@prisma\client +0ms
prisma:generator baseDir C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\prisma +1ms
prisma:generator typescriptPath undefined +2ms
prisma:GeneratorProcess 2022-03-09T13:17:40.083Z prisma:client:generator requiredEngine: queryEngine +0ms
prisma:getGenerators neededVersions {
"73e60b76d394f8d37d8ebd1f8918c79029f0db86": {
"engines": [
"queryEngine"
],
"binaryTargets": []
}
} +0ms
prisma:getGenerators {
prisma:getGenerators generatorBinaryPaths: {
prisma:getGenerators queryEngine: {
prisma:getGenerators windows: 'C:\\Users\\Admin\\Desktop\\Proyectos\\tests\\test-prisma-stringify\\node_modules\\prisma\\query-engine-windows.exe'
prisma:getGenerators }
prisma:getGenerators }
prisma:getGenerators } +212ms
prisma:GeneratorProcess 2022-03-09T13:17:49.699Z prisma:loadEnv project root found at C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\package.json +10s
prisma:tryLoadEnv Environment variables loaded from C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\.env +0ms
Error: Error:
RangeError: Invalid string length
at JSON.stringify (<anonymous>)
at respond (C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\@prisma\client\generator-build\index.js:54245:22)
at LineStream.<anonymous> (C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\@prisma\client\generator-build\index.js:54187:9)
at Object.parse (C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\prisma\build\index.js:107298:15)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async main (C:\Users\Admin\Desktop\Proyectos\tests\test-prisma-stringify\node_modules\prisma\build\index.js:108740:18)
We will be glad to give you more information if you need it. Thanks for such an amazing ORM
How to reproduce
- Create a new npm project
- Install prisma and prisma client (
npm i prisma
andnpm i -D @prisma/client
) - Run
npx prisma generate
with a big schema.prisma file (ours has more than 3400 lines and about 162k characters without spaces) - See error
Expected behavior
The prisma client should be able to generate the models from our schema
Prisma information
Unfortunately we can’t give you the schema.prisma that we area using right now. We think that with the information we are giving you, it should be possible to reproduce the same error.
The schema.prisma file has about 3400 lines and 162k characters with a total of 136 models in it.
Environment & setup
We tried with different setups
- OS: Windows 64 bits and Linux (node image in docker)
- Database: PostgreSQL
- Node.js version: v14.17.1, v16.14.0 and v14.19.0
Prisma Version
Executed npx prisma -v The project originally uses prisma version 2, we tried with the latest version but we got the same results
Prisma 2.26.0:
prisma : 2.26.0
@prisma/client : 2.26.0
Current platform : windows
Query Engine : query-engine 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine : migration-engine-cli 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : 9b816b3aa13cc270074f172f30d6eda8a8ce867d
Studio : 0.408.0
Prisma 3.10.0:
prisma : 3.10.0
@prisma/client : 3.10.0
Current platform : windows
Query Engine (Node-API) : libquery-engine 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine : migration-engine-cli 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : 73e60b76d394f8d37d8ebd1f8918c79029f0db86
Studio : 0.458.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:23 (9 by maintainers)
Top GitHub Comments
@millsp It worked! I installed
@prisma/client@dev
andprisma@dev
Screenshot:
Output of npx prisma-v:
Thank you so much to everyone involved in this issue!