question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prisma client not working with aws lambda

See original GitHub issue

Issue 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 or alpha @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 old serverless-next.js component and the serverless-next.js plugin are deprecated and no longer maintained.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:14

github_iconTop GitHub Comments

2reactions
amitleuva1987commented, Jul 15, 2022

@shengslogar , It just started working for me. Thank you very much. I also came across your Laravel breadcrumb package. You are doing great job…

2reactions
shengslogarcommented, Jul 13, 2022

Was able to resolve by adding useServerlessTraceTarget: true to my serverless.yml.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploying to AWS Lambda - Prisma
In this guide, you will set up and deploy a serverless Node.js REST API to AWS Lambda using the Serverless Framework. AWS Lambda...
Read more >
Prisma client is not working with next js serverless when ...
serverless_nextjs/default-lambda/', it automatically get disappear after I run serverless. This is the url to my repo which works fine with " ...
Read more >
Troubleshoot deployment issues in Lambda
Learn how to troubleshoot common deployment issues in Lambda. ... with a client such as the AWS CLI, you can see errors from...
Read more >
How to deploy Prisma in AWS Lambda with Serverless
Prisma is an ORM where a TypeScript client is generated based on a schema so consuming apps have type-safety when querying databases. It...
Read more >
Ryan Dsouza - Deploying Prisma on Lambda using the CDK
In this talk you will learn how Prisma combined with the CDK make deploying and interacting with your database easy on Serverless◭Ryan is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found