zod-prisma-types icon indicating copy to clipboard operation
zod-prisma-types copied to clipboard

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

Open CyanoFresh opened this issue 1 year ago • 5 comments

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/[email protected] postinstall node_modules/@prisma/client node scripts/postinstall.js
481 info run @prisma/[email protected] postinstall node_modules/@prisma/engines node scripts/postinstall.js
482 info run @prisma/[email protected] postinstall { code: 0, signal: null }
483 timing build:run:postinstall:node_modules/@prisma/engines Completed in 5075ms
484 info run @prisma/[email protected] 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 [email protected] 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/[email protected]
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:

  • node:18-alpine:
    • with npx - process cannot finish
    • without npx - error: cannot find module
  • macos:
    • with npx - process cannot finish
    • without npx - works fine

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

CyanoFresh avatar Aug 04 '23 12:08 CyanoFresh

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

skve avatar Sep 18 '23 20:09 skve

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
}

skve avatar Sep 18 '23 20:09 skve

Same issue

breagan1983 avatar Oct 26 '23 14:10 breagan1983

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

CyanoFresh avatar Oct 26 '23 15:10 CyanoFresh

Try npx --yes zod-prisma-types

ericallam avatar Sep 23 '24 21:09 ericallam