Query engine binary not found while deploying Next.js App to AWS using Serverless Framework
See original GitHub issueBug description
I’m using the serverless component for next.js to deploy my app to AWS. Unfortunately, things didn’t go smoothly as expected. While testing the cloudfront distribution will try to execute a query from the nextjs api routes through the lambda.
The cloudfront will throw the following error:
503 ERROR
The request could not be satisfied.
The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
Generated by cloudfront (CloudFront)
Request ID: 63bKSGDPOK1vnJwOxPuvkR9dTEsqgqBFpeXpx3KKCiGMAeXfPtBt4w==
Looking inside the lambda logs I found out that the query engine binary was not found and the database couldn’t be reached. here’s the error thrown by the lambda:
"stack": [
"Error: Query engine binary for current platform \"rhel-openssl-1.0.x\" could not be found.",
"This probably happens, because you built Prisma Client on a different platform.",
"(Prisma Client looked in \"/query-engine-rhel-openssl-1.0.x\")",
"",
"Searched Locations:",
"",
" /.prisma/client",
" /home/user/Documents/workspace/project/node_modules/@prisma/client",
" /",
" /var/task/node_modules/.prisma/client",
" /var/task",
" /var/task/node_modules/.prisma/client",
"",
"You already added the platforms \"native\", \"rhel-openssl-1.0.x\" to the \"generator\" block",
"in the \"schema.prisma\" file as described in https://pris.ly/d/client-generator,",
"but something went wrong. That's suboptimal.",
"",
"Please create an issue at https://github.com/prisma/prisma-client-js/issues/new",
" at PrismaClientFetcher.request (/var/task/pages/api/auth/[...nextauth].js:155205:15)"
]
What I tried
Following https://github.com/prisma/docs/issues/841 I tried to copy the relevant files during the deployment. I tried also to change the default location of the binary following https://github.com/serverless-nextjs/serverless-next.js/issues/843 but nothing worked.
How to reproduce
Steps to reproduce the behavior:
- Create a nextjs App with next-auth and prisma for passwordless login
- Deploy to aws using serverless. The exact component is
'@sls-next/serverless-component@1.18.0'
- Test the login with the production environment
- See error
Expected behavior
The query engine binary will be correctly generated and be able to query the database without errors.
Prisma information
I think the following is the only relative information for the issue.
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "rhel-openssl-1.0.x"]
}
Environment & setup
- OS: Linux Mint 20 Cinnamon
- Database: PostgreSQL
- Node.js version: v12.15.0
- Prisma: 2.14.0
@prisma/cli : 2.14.0
@prisma/client : 2.14.0
Current platform : debian-openssl-1.1.x
Query Engine : query-engine 5d491261d382a2a5ffdc71de17072b0e409f1cc1 (at node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x)
Migration Engine : migration-engine-cli 5d491261d382a2a5ffdc71de17072b0e409f1cc1 (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 5d491261d382a2a5ffdc71de17072b0e409f1cc1 (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary : prisma-fmt 5d491261d382a2a5ffdc71de17072b0e409f1cc1 (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Studio : 0.332.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:24 (5 by maintainers)
@janpio Sorry for my late reply 🥲 Here are my
serverless.yml
codes below. It referenced #5392 (comment), -> https://github.com/millsp/prisma-serverless-nextjsThis can be solved by adding a script that triggers before upload. I have set a template up for prisma + serverless-next.js which adds a
postBuildCommands
(serverless.yml
) script to do just that.