Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeError: Invalid count value during prisma generate #16126

Closed
niksrc opened this issue Nov 3, 2022 · 1 comment · Fixed by #16227
Closed

RangeError: Invalid count value during prisma generate #16126

niksrc opened this issue Nov 3, 2022 · 1 comment · Fixed by #16227
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: cli
Milestone

Comments

@niksrc
Copy link

niksrc commented Nov 3, 2022

Bug description

I'm getting the following error every time I run prisma generate on GitHub Actions:

Error: RangeError: Invalid count value
    at String.repeat (<anonymous>)
    at /home/runner/work/model/node_modules/prisma/build/index.js:92469:13
    at Array.map (<anonymous>)
    at drawBox (/home/runner/work/model/node_modules/prisma/build/index.js:92464:44)
    at printUpdateMessage (/home/runner/work/model/node_modules/prisma/build/index.js:98209:24)
    at main (/home/runner/work/model/node_modules/prisma/build/index.js:98407:5)

Here are the full debug logs:

2022-10-20T13:19:14.359Z prisma:engines  binaries to download libquery-engine, migration-engine, introspection-engine, prisma-fmt
2022-10-20T13:19:16.455Z prisma:loadEnv  project root found at /home/runner/work/model/package.json
2022-10-20T13:19:16.465Z prisma:tryLoadEnv  Environment variables not found at null
2022-10-20T13:19:16.466Z prisma:tryLoadEnv  Environment variables not found at undefined
2022-10-20T13:19:16.466Z prisma:tryLoadEnv  No Environment variables loaded
Prisma schema loaded from prisma/schema.prisma
2022-10-20T13:19:16.925Z prisma:getConfig  Using CLI Query Engine (Node-API Library) at: /home/runner/work/model/node_modules/prisma/libquery_engine-debian-openssl-1.1.x.so.node
2022-10-20T13:19:16.930Z prisma:getConfig  Loaded Node-API Library
2022-10-20T13:19:16.932Z prisma:getConfig  config data retrieved without errors in getConfigNodeAPI
2022-10-20T13:19:16.949Z prisma:getDMMF  Using CLI Query Engine (Node-API Library) at: /home/runner/work/model/node_modules/prisma/libquery_engine-debian-openssl-1.1.x.so.node
2022-10-20T13:19:16.950Z prisma:getDMMF  Loaded Node-API Library
2022-10-20T13:19:16.974Z prisma:getDMMF  unserialized dmmf result ready
2022-10-20T13:19:16.987Z prisma:getDMMF  dmmf retrieved without errors in getDmmfNodeAPI
2022-10-20T13:19:17.018Z prisma:generator  prismaCLIDir /home/runner/work/model/node_modules/prisma
2022-10-20T13:19:17.018Z prisma:generator  prismaClientDir /home/runner/work/model/node_modules/@prisma/client
2022-10-20T13:19:17.018Z prisma:generator  baseDir /home/runner/work/model/prisma
2022-10-20T13:19:17.022Z prisma:generator  typescriptPath /home/runner/work/model/node_modules/typescript
2022-10-20T13:19:17.238Z prisma:GeneratorProcess  2022-10-20T13:19:17.236Z prisma:client:generator  requiredEngine: libqueryEngine
2022-10-20T13:19:17.238Z prisma:getGenerators  neededVersions {
  "5a48a95376daf2f71f434e8f77a3eeb9943d997b": {
    "engines": [
      "libqueryEngine"
    ],
    "binaryTargets": []
  }
}
2022-10-20T13:19:17.681Z prisma:getGenerators  {
  generatorBinaryPaths: {
    libqueryEngine: {
      'debian-openssl-1.1.x': '/home/runner/work/model/node_modules/prisma/libquery_engine-debian-openssl-1.1.x.so.node'
    }
  }
}
2022-10-20T13:19:17.788Z prisma:GeneratorProcess  2022-10-20T13:19:17.787Z prisma:loadEnv  project root found at /home/runner/work/model/package.json
2022-10-20T13:19:18.081Z prisma:tryLoadEnv  Environment variables not found at null
2022-10-20T13:19:18.081Z prisma:tryLoadEnv  Environment variables not found at undefined
2022-10-20T13:19:18.081Z prisma:tryLoadEnv  No Environment variables loaded

✔ Generated Prisma Client (4.5.0-integration-use-keep-alive-for-node-fetch.1 | library) to ./node_modules/@prisma/client in 326ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
	```
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
	```
2022-10-20T13:19:18.140Z prisma:getConfig  Using CLI Query Engine (Node-API Library) at: /home/runner/work/model/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node
2022-10-20T13:19:18.142Z prisma:getConfig  Loaded Node-API Library
2022-10-20T13:19:18.145Z prisma:getConfig  config data retrieved without errors in getConfigNodeAPI
Error: RangeError: Invalid count value
    at String.repeat (<anonymous>)
    at /home/runner/work/model/node_modules/prisma/build/index.js:92469:13
    at Array.map (<anonymous>)
    at drawBox (/home/runner/work/model/node_modules/prisma/build/index.js:92464:44)
    at printUpdateMessage (/home/runner/work/model/node_modules/prisma/build/index.js:98209:24)
    at main (/home/runner/work/model/node_modules/prisma/build/index.js:98407:5)

On GitHub Actions, for some strange reason, paddingRight is less than horizontalPadding resulting in " ".repeat getting a negative value:

)}${' '.repeat(paddingRight - horizontalPadding!)}${chalk.grey(chars.vertical)}`

I've been using this patch as a workaround to solve the issue:

@@ -92463,7 +92463,7 @@ function drawBox({ title, width, height, str, horizontalPadding }) {
   }
   const mappedLines = lines.slice(-height).map((l2) => {
     const lineWidth = Math.min((0, import_string_width.default)(l2), width);
-    const paddingRight = Math.max(width - lineWidth - 2, 0);
+    const paddingRight = Math.max(width - lineWidth - 2, 0, horizontalPadding);
     return `${import_chalk23.default.grey(chars.vertical)}${" ".repeat(horizontalPadding)}${import_chalk23.default.reset(
       (0, import_cli_truncate.default)(l2, width - 2)
     )}${" ".repeat(paddingRight - horizontalPadding)}${import_chalk23.default.grey(chars.vertical)}`;

Expected behavior

prisma migrate should not fail with the error

Environment & setup

Prisma Version

prisma                  : 4.5.0-integration-use-keep-alive-for-node-fetch.1
@prisma/client          : 4.5.0-integration-use-keep-alive-for-node-fetch.1
Current platform        : darwin-arm64
Query Engine (Node-API) : libquery-engine 5a48a95376daf2f71f434e8f77a3eeb9943d997b (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine        : migration-engine-cli 5a48a95376daf2f71f434e8f77a3eeb9943d997b (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine    : introspection-core 5a48a95376daf2f71f434e8f77a3eeb9943d997b (at node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary           : prisma-fmt 5a48a95376daf2f71f434e8f77a3eeb9943d997b (at node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Format Wasm             : @prisma/prisma-fmt-wasm 4.5.0-34.5a48a95376daf2f71f434e8f77a3eeb9943d997b
Default Engines Hash    : 5a48a95376daf2f71f434e8f77a3eeb9943d997b
Studio                  : 0.475.0
@niksrc niksrc added the kind/bug A reported bug. label Nov 3, 2022
@janpio
Copy link
Member

janpio commented Nov 4, 2022

I remember we had an issue about something like this before...

Oh yeah, it was mine! #9429

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: cli
Projects
None yet
3 participants