Hello! I am using Prisma with NestJS and PlanetSca...
# orm-help
s
Hello! I am using Prisma with NestJS and PlanetScale, which is deployed to a Lambda. I have made the query engine binary available as a layer. The location of this layer is:
Copy code
/opt/prisma-binary
I have set the above value as
PRISMA_QUERY_ENGINE_BINARY
. When I try to run a
create
request, I get the following error:
Copy code
Invalid `this.prisma.user.create()` invocation in
/var/task/src/lambda.js:482655:43

  482652     throw new Error("Not found. Proceeding to create!");
  482653   }
  482654 } catch (_a4) {
→ 482655   user = await this.prisma.user.create(
  spawn /opt/prisma-binary EACCES
    at RequestHandler.request (/var/task/src/lambda.js:123709:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async PrismaService._request (/var/task/src/lambda.js:124590:22)
    at async AuthService.verifyOTP (/var/task/src/lambda.js:482655:20) {
  code: 'EACCES',
  clientVersion: '3.15.2',
  meta: undefined
}
This works locally, but gives the above error on lambda. Any idea why?
👀 1
g
it sounds like prisma dependency is missing
g
EACCES code - means that you have no enough permission to that dir or file
n
I agree, to me, it looks like an Access/Permission issue as well. Were you able to solve this?
s
No. I wasn't. Any idea what I can do to solve this? Why can't my app access the directory?
n
Did you had a look at this Guide - Deploying to AWS Lambda?
s
This is what I'm doing. This is about packaging, I don’t have any issue packaging. The layers are also accessible. But I get an EACCESS error
s
This is about the package. The error I'm getting says that it's an
EACCESS
on
/opt/Prisma-binary
folder which is where my lambda layer is
n
Is your code open source? If it is could you share the repo so I could try to replicate it and debug?
s
Unfortunately it isn't, but I cold send it to you.
Would it also be worth mentioning that I'm running it on ARM and not the x86 machines?
n
I would recommend providing a public minimal reproduction so that I could share it within our engineering team as well if needed.
s
I'll share the entire source code as a zip and you can deploy and check
r
Hi @Samrith Shankar - check out my repo here: https://github.com/richardwardza/prisma-lambda-layers It's using Prisma in a lambda layer with the work around like you've mentioned (
PRISMA_QUERY_ENGINE_BINARY
, etc)
it's also quite a nice setup for local development
s
Thanks! I'll check it out!