Prisma client not working with aws lambda
See original GitHub issueIssue Summary
I am not sure if it is bug or a new feature request. I am using next js “12.1.6”. I have installed “@prisma/client”: “^3.15.2” . I am trying to go serverless with aws. when I start deploying the app, it doesn’t show any error. It creates “lambda functions” and static stuff in “aws s3” and provides a cloudfront url. when I visit the deployed app, it show me 503 error. If I remove the prisma portion, the app starts running properly.
FYI : I use mysql database created on “railway.app.”. I hope serverless support railway.app databases when deployed with aws lambda.
Actual behavior
the deployed app return 503 error. I am new to aws and not able to see the logs.
Expected behavior
It should return a list of users in index page. below is the code to display users from table.
export async function getServerSideProps(content) {
const prisma = new PrismaClient()
const users = await prisma.user.findMany({
select: {
id: true,
email: true,
}
})
return {
props : { users }
}
}
Steps to reproduce
I already have the repo over github which is running fine with vercels. below is the git repo url. https://github.com/amitleuva1987/full-stack-nextjs-with-prisma
Screenshots/Code/Configuration/Logs
below is my serverless.yml file
myNextApp:
component: "@sls-next/serverless-component"
below is .env file
NEXTAUTH_URL="https://d1vl8g8lv7yuwi.cloudfront.net" // I have taken the app down, this url may not work
DATABASE_URL="********" // prisma proxy url
MIGRATE_DATABASE_URL="*****" // railay.app mysql db
PRISMA_CLIENT_ENGINE_TYPE='dataproxy'
GIT_ID="*********"
GIT_SECRET="********"
EMAIL_SERVER="******"
EMAIL_FROM=NextAuth <noreply@example.com>
Versions
"@next-auth/prisma-adapter": "^1.0.3",
"@prisma/client": "^3.15.2",
"bcryptjs": "^2.4.3",
"bootstrap": "^5.1.3",
"next": "12.1.6",
"next-auth": "4.8.0",
"nodemailer": "^6.7.6",
"react": "18.2.0",
"react-dom": "18.2.0",
"swr": "^1.3.0"
Additional context
The app works very well with vercels and in my local pc. Below is an open issue which needs attention. issue url
Below repo is one of the promising solution which did not work in my case. repo url
Checklist
- I have reviewed the README and FAQs, which answers several common questions.
- I have reviewed our DEBUGGING wiki and have tried my best to include complete information and reproduction steps (including your configuration) as is possible. As there is only one maintainer (who maintains this in his free time) and thus very limited resources, if you have time, please try to debug the issue a bit yourself if possible.
- You have first tried using the most recent
latest
oralpha
@sls-next/serverless-component
release version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the oldserverless-next.js
component and theserverless-next.js
plugin are deprecated and no longer maintained.
Issue Analytics
- State:
- Created a year ago
- Comments:14
Top GitHub Comments
@shengslogar , It just started working for me. Thank you very much. I also came across your Laravel breadcrumb package. You are doing great job…
Was able to resolve by adding
useServerlessTraceTarget: true
to myserverless.yml
.