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

PrismaJS not working since process.chdir cannot be used in workers #263

Open
1 task done
Phill030 opened this issue Apr 29, 2023 · 6 comments
Open
1 task done

PrismaJS not working since process.chdir cannot be used in workers #263

Phill030 opened this issue Apr 29, 2023 · 6 comments
Labels
type: bug Something isn't working

Comments

@Phill030
Copy link

Description of the problem

When trying to use PrismaJS, you'll instantly get the error, that process.chdir() is not supported in workers. The only workaround for that right now, is to use the wsl, which would be very laborious to setup just for one project.

Reproduction steps

  1. install PrismaJS within a project.
  2. fix the N-API error, by setting engineType = "binary" in the client in your schema
  3. generate your prisma client using yarn prisma generate or npx prisma generate
  4. start your server

Expected behaviour

There should be no error saying

[18:07:36][Error] Uncaught exception: Error: 
Invalid `prisma.account.count()` invocation:

process.chdir() is not supported in workers

Additional context

No response

Operating system

Windows 10

Version

15.0-dev79

Scope

server

Reproduction tested

  • I confirm that I have made sure that this issue is also present on the newest dev version
@Phill030 Phill030 added the type: bug Something isn't working label Apr 29, 2023
@yannbcf
Copy link
Contributor

yannbcf commented Apr 29, 2023

Aslong as you need to set engineType = "binary" I dont recommend using Prisma within the alt:V serverside context, it makes prisma setup a local websocket server to communicate with their rust query builder rather than using the node ffi api and it is drasticaly slower.

@Phill030
Copy link
Author

So this would theoretically need to be fixed by alt:V?

@JamessDev
Copy link

Yes

@a-zzura
Copy link

a-zzura commented Jul 3, 2023

any updates on this issue?

@Yiin
Copy link

Yiin commented Sep 3, 2023

@15322107
https://discord.com/channels/371265202378899476/371271006360436757/1146704764751577152

Leon — 08/31/2023 10:14 AM
And no there is no fix planned, ask the nodejs devs to make it work xd
<...> alt:V uses a completely standard nodejs build
It doesn't have a single line of the source code modified, but it doesn't work because
¯\_(ツ)_/¯

Although if you're not querying the database 1000 times per second, that "drastically slower" performance is really not an issue. For loading/saving the player and doing occasional query for some menu you might as well could use google sheets and players would notice no difference whatsoever.

@Yiin
Copy link

Yiin commented Feb 9, 2024

@15322107

any updates on this issue?

I'm using this setup as workaround:

setup-globals.ts

// Until prisma starts supporting ESM, this is the workaround
import { createRequire } from "module";

global.require = createRequire(import.meta.url);
process.chdir = () => {};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants