zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.07k stars 88 forks source link

Swap `fs` with `node-graceful-fs` for more robust cross operating system support #705

Closed sitch closed 7 months ago

sitch commented 1 year ago

After upgrading from v1.0.0-beta.21 to v1.0.0-beta.23 I started receiving the following error:

⌛️ ZenStack CLI v1.0.0-beta.23, running plugins
- Running plugin Prisma
Prisma schema loaded from prisma/schema.prisma
Formatted PROJECT_DIR/libs/db/prisma/schema.prisma in 30ms 🚀
✔ Running plugin Prisma
- Running plugin Model Metadata
✔ Running plugin Model Metadata
- Running plugin Access Policy
✔ Running plugin Access Policy
- Running plugin Zod
✖ Running plugin Zod

An unexpected error occurred:
[Error: EMFILE: too many open files, open 'PROJECT_DIR/node_modules/.zenstack/zod/objects/ImagePredictionUncheckedCreateWithoutPhotoInput.schema.js'] {
  errno: -24,
  code: 'EMFILE',
  syscall: 'open',
  path: 'PROJECT_DIR/node_modules/.zenstack/zod/objects/ImagePredictionUncheckedCreateWithoutPhotoInput.schema.js'
}

An unexpected error occurred:
[Error: EMFILE: too many open files, open 'PROJECT_DIR/node_modules/.zenstack/zod/objects/ImagePredictionUncheckedCreateWithoutPhotoInput.schema.js'] {
  errno: -24,
  code: 'EMFILE',
  syscall: 'open',
  path: 'PROJECT_DIR/node_modules/.zenstack/zod/objects/ImagePredictionUncheckedCreateWithoutPhotoInput.schema.js'
}

Unfortunately, a more detailed error stack isn't included, but the error suggests OS open file limit reached.

The lib node-graceful-fs is a drop-in replacement for fs and automatically handles this category of issue without having to modify /etc/security/limits.conf on linux or god knows what for windows

sitch commented 1 year ago

Also, if the source of this error is tsc or another external tool, OS settings would be required and the node-graceful-fs recommendation would be irrelevant

ymc9 commented 1 year ago

Thanks for pointing me to that package! I'll look into it. The problem probably likes in "ts-morph" (used to do TS generation and emit JS files).

ymc9 commented 7 months ago

Resolving for now. Please reactivate if you still run into it.