Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct config for Prisma with Supabase on Cloudflare #241

Open
mtzrmzia opened this issue Aug 24, 2024 · 5 comments
Open

Correct config for Prisma with Supabase on Cloudflare #241

mtzrmzia opened this issue Aug 24, 2024 · 5 comments
Labels
question Further information is requested

Comments

@mtzrmzia
Copy link

Describe the bug
I'm trying to relocate my Vercel projects to Cloudflare through NuxtHub. I'm using Prisma ORM with Supabase and on Vercel deploy the project works as expected, but in Cloudflare not. I got 500: Cannot read properties of undefined (reading 'exec'). error but in local works!

Steps to reproduce
Steps to reproduce the behavior:

  1. Install prisma and @prisma/client dependencies then add prisma generate to build command:
{
  "name": "esteba-app-appointments",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "prisma generate && nuxt build",
  },
  "dependencies": {
    "@prisma/client": "^5.18.0",
    "@vueuse/core": "^11.0.1",
    "nuxt": "^3.13.0",
    "vue": "latest",
  },
  "devDependencies": {
    "prisma": "^5.18.0",
    "wrangler": "^3.72.2"
  },
  "packageManager": "yarn@1.22.22"
}
  1. Create prisma/schema.prisma file:
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}
  1. set supabase credentials on environment variables project

and thats it, on Vercel this works

Expected behavior
Request sent as expected

I'm doing my research, and this issue happens to another person Cloudflare issue

@atinux
Copy link
Contributor

atinux commented Aug 24, 2024

Duplicate of #38

Would you mind reading https://github.com/nuxt-hub/core/pull/58/files and see if this works?

@atinux atinux added the question Further information is requested label Aug 24, 2024
@mtzrmzia
Copy link
Author

Duplicate of #38

Would you mind reading https://github.com/nuxt-hub/core/pull/58/files and see if this works?

The example uses sqlite and ignores the DATABASE_URL but i'm using postgresql with supabase... just dont work

Copy link
Contributor

atinux commented Aug 24, 2024

@CristobalMedrano
Copy link

I had a similar problem, you could try this prisma/prisma#23500 (comment). It seems to be a problem with Nitro and Prisma

@EthanITA
Copy link

@mtzrmzia I'm late, but in case someone else is having trouble using Supabase + ORM + Cloudflare.

I did some research and found that Cloudflare Workers aren't based on Node, but on V8 which has a subset of the features of Node. That means if you use an ORM, it'll use default a TCP connection to your DB, which it shouldn't be supported afaik from Cloudflare Workers.

So, the solution is either you ditch:

  • Supabase for another DB with http support (like Neon or D1)
  • Prisma to use "supabasejs" and use PostgREST (to avoid TCP)
  • Cloudflare Workers to other serverless platforms that support TCP (like Vercel)

In my case I decided to migrate my DB to Neon, because it was the fastest and with fewer conflicts to my workflows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants