AWS Amplify Gen 2 Error Client
Hi, Im tryin to use prisma in my Amplify Gen 2 Function, the binaries are created correctly in local (Mac M4) but when I do npx ampx sandbox and execute the function I receive the following error:
Invalid
prisma.avisos_de_marca.upsert()
invocation:
Prisma Client could not locate the Query Engine for runtime "linux-arm64-openssl-3.0.x".
This is likely caused by a bundler that has not copied "libquery_engine-linux-arm64-openssl-3.0.x.so.node" next to the resulting bundle.
Ensure that "libquery_engine-linux-arm64-openssl-3.0.x.so.node" has been copied next to the bundle or in "node_modules/.prisma/client".
We would appreciate if you could take the time to share some information with us.
Please help us by answering a few questions: https://pris.ly/engine-not-found-bundler-investigation
The following locations have been searched:
/var/task/node_modules/.prisma/client
/var
/app/node_modules/@prisma/client
/.prisma/client
/tmp/prisma-engines
at Age.handleRequestError (file:///var/task/index.mjs:173:7792)
at Age.handleAndLogRequestError (file:///var/task/index.mjs:173:6809)
at Age.request (file:///var/task/index.mjs:173:6516)
at async c (file:///var/task/index.mjs:182:9850)
at async Runtime.cGe [as handler] (file:///var/task/index.mjs:244:38819) {
clientVersion: '6.13.0',
errorCode: undefined,
retryable: undefined
}
My schema is:
generator client {
provider = "prisma-client-js"
binaryTargets = ["linux-arm64-openssl-3.0.x"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
#help-and-questions4 Replies
Ahoy, knowledge seeker! I'm the Prisma AI Help Bot. Do you want a dev's response that might take a hot second, or an AI answer that's ready before your next coffee sip? Either way, your question is important to us.
Hey!
The issue you are running into seems similar to these:
- https://github.com/prisma/prisma/issues/26976
- https://github.com/prisma/prisma/issues/26831
Does one of the solution mentioned in these help?
GitHub
Query engine not found Serverless AWS Lambda Ā· Issue #26976 Ā· pri...
Bug description Related to issue: #8483 in my schema.prisma I have the following setup `generator client { provider = "prisma-client-js" binaryTargets = ["native", "rhel-op...
GitHub
Bug: Prisma Query Engine not bundled in Vercel Serverless (Expo Rou...
Bug description Hey all ā just confirming that this issue still happens in non-Next.js setups too. Iām using Expo Router with API routes deployed on Vercel via @expo/server/adapter/vercel, and the ...
Hi! @Nurul
I just follow the steps mentioned in (https://github.com/prisma/prisma/issues/26976)
And works great.
In my case amplify gen 2 just follow this steps:
1. Locate where Prisma generated your client
2. Look for .so.node files - these are the missing engine files
3. You will need just one - for Node >=20, the one with openssl-3 in name (afaik)
3. Create Lambda Layer with this file - how to do that depends on your setup, so refer to AWS Documentation on Lambda Layers
4. Set PRISMA_QUERY_ENGINE_LIBRARY env variable to path to the .so.node file. In case of my Layer which contains just the file in it's root directory, it looks like this PRISMA_QUERY_ENGINE_LIBRARY='/opt/nodejs/libquery_engine-rhel-openssl-3.0.x.so.node'
To invoke envars and layers in gen 2 function check https://docs.amplify.aws/vue/build-a-backend/functions/add-lambda-layers/
To create the layer, do following steps:
1. Crea una estructura de carpetas localmente:
mkdir -p layer/nodejs
cp node_modules/.prisma/client/libquery_engine-rhel-openssl-3.0.x.so.node layer/nodejs/
2. Empaqueta el contenido:
cd layer
zip -r layer.zip .
3. Sube como una Lambda Layer desde la consola de AWS
I am glad to hear that this was fixed š