chrishoermann / zod-prisma-types

Generator creates zod types for your prisma models with advanced validation
Other
579 stars 43 forks source link

`npx zod-prisma-types` prevents postinstall from completing #170

Open CyanoFresh opened 11 months ago

CyanoFresh commented 11 months ago

When using

generator zod {
  provider                  = "npx zod-prisma-types"
}

npm i command doesn't complete, hanging forever. Without npx prefix it's not working:

/bin/sh: zod-prisma-types: not found

This completely breaks my CI pipeline. Only commenting the generator zod fixes the problem.

If I interrupt the process, npm log:

480 info run @prisma/client@5.1.1 postinstall node_modules/@prisma/client node scripts/postinstall.js
481 info run @prisma/engines@5.1.1 postinstall node_modules/@prisma/engines node scripts/postinstall.js
482 info run @prisma/engines@5.1.1 postinstall { code: 0, signal: null }
483 timing build:run:postinstall:node_modules/@prisma/engines Completed in 5075ms
484 info run @prisma/client@5.1.1 postinstall { code: null, signal: 'SIGINT' }
485 timing reify:rollback:createSparse Completed in 161ms
486 timing reify:rollback:retireShallow Completed in 0ms
487 timing command:ci Completed in 173558ms
488 notice
488 notice New minor version of npm available! 9.6.7 -> 9.8.1
488 notice Changelog: https://github.com/npm/cli/releases/tag/v9.8.1
488 notice Run npm install -g npm@9.8.1 to update!
488 notice
489 verbose stack Error: command failed
489 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
489 verbose stack     at ChildProcess.emit (node:events:514:28)
489 verbose stack     at maybeClose (node:internal/child_process:1091:16)
489 verbose stack     at Socket.<anonymous> (node:internal/child_process:449:11)
489 verbose stack     at Socket.emit (node:events:514:28)
489 verbose stack     at Pipe.<anonymous> (node:net:323:12)
490 verbose pkgid @prisma/client@5.1.1
491 verbose cwd /app
492 verbose Linux 5.15.49-linuxkit-pr
493 verbose node v18.17.0
494 verbose npm  v9.6.7
495 error path /app/node_modules/@prisma/client
496 error command failed
497 error signal SIGINT
498 error command sh -c node scripts/postinstall.js
499 error Prisma schema loaded from libs/prisma/schema.prisma
499 error
499 error ✔ Generated Prisma Client (5.1.1 | library) to ./node_modules/@prisma/client in 186ms
499 error
499 error ✔ Generated Zod Prisma Types to ./libs/schema/src/prisma-generated in 260ms
499 error You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
499 error ```
499 error import { PrismaClient } from '@prisma/client'
499 error const prisma = new PrismaClient()
499 error ```
500 verbose exit 1
501 timing npm Completed in 173683ms
502 verbose unfinished npm timer reify 1691147778961
503 verbose unfinished npm timer reify:build 1691147781282
504 verbose unfinished npm timer build 1691147781282
505 verbose unfinished npm timer build:deps 1691147781282
506 verbose unfinished npm timer build:run:postinstall 1691147781334
507 verbose unfinished npm timer build:run:postinstall:node_modules/@prisma/client 1691147781334
508 verbose code 1

OS:

zod-prisma-types version: 2.7.7 Prisma version: 5.1.1

skve commented 9 months ago

Any movement on this or pointers? Happy to help on this.

skve commented 9 months ago

A hacky fix is to exit the process after 5 seconds:

generator zod {
  // Process never exits, bug: https://github.com/chrishoermann/zod-prisma-types/issues/170
  provider         = "perl -e 'alarm 5; exec @ARGV' npx zod-prisma-types"
  output           = "./models"
  createInputTypes = false
}

timeout is available on unix, but not macOS by default. If your environment is entirely linux/unix, you could also use the cleaner:

generator zod {
  // Process never exits, bug: https://github.com/chrishoermann/zod-prisma-types/issues/170
  provider         = "timeout 5s npx zod-prisma-types"
  output           = "./models"
  createInputTypes = false
}
breagan1983 commented 8 months ago

Same issue

CyanoFresh commented 8 months ago

perl is working fine for me, but now every prisma generate takes 5s. for some reason timeout is not working for alpine docker build