Having Trouble integrating Supabase with Wasp

I am using a M2 Mac. I installed the wasp-lang installer using the curl command provided in the Getting Started Documentation. After that I created a new Wasp Project and selected the [3] SAAS option. It created my file and folder structure. I was able to open this up in VS Code and I was able to access the different sections. I went into the .env.server.example env file and renamed it .env.server. I then went to Supabase and created a postgres database. I copied the link from Project Settings>Database>Connection String>URI and pasted that in my .env.server file with the variable DATABASE_URL. I then went back to my terminal and navigated into the "app" directory of my wasp project. From there I typed wasp db migrate-dev, upon doing that the wasp project was compiled and NPM install was completed. However it gets stuck on the Setting up database section and never finishes loading. To circumvent this I decided to set the .env variable DATABASE_URL inline as referenced in the documentation (1). However I was stuck waiting again in the Setting up database section. (1) Connecting to outside Postgres server documentation https://wasp-lang.dev/docs/data-model/backends#connecting-to-a-database
19 Replies
kapa.ai
kapa.ai5mo ago
Hi @AibohpDealer54. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- It seems like you've followed the correct steps to connect your Wasp project to an external PostgreSQL database hosted on Supabase. However, the issue you're experiencing might be due to a variety of factors. Here are a few things you can check: 1. Database URL: Ensure that the DATABASE_URL you've set in your .env.server file or inline is correct. It should be the connection string provided by Supabase. 2. Database Accessibility: Make sure that your database on Supabase is accessible from your development environment. You might need to check your network settings or firewall rules. 3. System Resources: If the process gets stuck at "Setting up database", it might be due to insufficient system resources. This was mentioned in a Discord support thread (https://discord.com/channels/686873244791210014/1217483832404611195) where running wasp db migrate-dev on an EC2 instance with limited memory caused the process to hang. 4. Wasp and Prisma Versions: Ensure you're using the latest versions of Wasp and Prisma. There have been issues reported on the Wasp GitHub page where database initialization failed due to a regression in a specific feature. Although these issues were marked as closed, it's worth checking if you're using a version of Wasp or Prisma that's known to work without these problems. If you're still experiencing issues after checking these points, I recommend reaching out to the Wasp community on their Discord server (https://discord.com/invite/rzdnErX) or opening an issue on the Wasp GitHub page (https://github.com/wasp-lang/wasp/issues). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @AibohpDealer54, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
AibohpDealer54
AibohpDealer545mo ago
Hello, how do I make sure that my supabase postgres server has enough system resources, because the process did get stuck at setting up database @kapa.ai
kapa.ai
kapa.ai5mo ago
Let me check the knowledge base for you. One moment! :books: Sorry @AibohpDealer54, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
AibohpDealer54
AibohpDealer545mo ago
@kapa.ai How do I ensure that I am using the latest versions of Prisma?
kapa.ai
kapa.ai5mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- To ensure you are using the latest version of Prisma, you can follow these steps: 1. Check the current version: You can check the current version of Prisma you are using by running the following command in your terminal:
npx prisma -v
npx prisma -v
This command will display the versions of Prisma CLI and Prisma Client you have installed. 2. Update Prisma: If you find that your Prisma version is not up-to-date, you can update it by running the following command:
npm install prisma@latest
npm install prisma@latest
This command will install the latest version of Prisma. Remember, Wasp uses a specific version of Prisma. As seen in the Github issues (https://github.com/wasp-lang/wasp/issues/194), Wasp has been updated to use specific versions of Prisma. So, before updating Prisma, make sure to check if the latest version is compatible with your current version of Wasp. If you are using Wasp, the Prisma version is defined in the package.json file in the generated project's ext/ directory. You can update the version there and run npm install in the ext/ directory to update Prisma. Always ensure to test your application thoroughly after updating Prisma, as there might be breaking changes in the new version. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @AibohpDealer54, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
AibohpDealer54
AibohpDealer545mo ago
Hello, how do I make sure that my supabase postgres server has enough system resources, because the process did get stuck at setting up database @kapa.ai
MEE6
MEE65mo ago
Wohooo @AibohpDealer54, you just became a Waspeteer level 1!
kapa.ai
kapa.ai5mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- To ensure your Supabase PostgreSQL server has enough system resources, you can follow these steps: 1. Check the server specifications: Log into your Supabase account and check the specifications of the server hosting your PostgreSQL database. Make sure it has enough memory (RAM) and storage space. The exact requirements can vary based on your application's needs, but as a reference, a Discord support thread (https://discord.com/channels/686873244791210014/1213593156646604820) mentioned that a server with 1GB of RAM was sufficient for their Wasp application. 2. Monitor server usage: Keep an eye on the server's resource usage, especially when running operations that require a lot of resources, such as setting up the database. You can use Supabase's built-in monitoring tools or third-party services to do this. 3. Upgrade the server if necessary: If you find that your server is consistently running out of resources, you might need to upgrade to a server with more memory or storage space. Remember, insufficient system resources can lead to various issues, including slow performance and failed operations. Therefore, it's important to ensure your server has enough resources to handle your application's needs. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @AibohpDealer54, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
martinsos
martinsos5mo ago
@AibohpDealer54 welcome! Db resources shouldn't be a problem, nor should your Prisma version be a problem. Check out this article on using Wasp with Supabase -> it is a bit high level, but it does link to example app which might be useful. https://dev.to/wasp/wasp-x-supabase-smokin-hot-full-stack-combo-ioe . Some quick ideas from my side: 1. Have you turned off wasp start db that you might have still running in another terminal? 2. Could you share what supabase url looks like, the one you put in DATABASE_URL (but do hide any sensitive information like password / secrets from it). 3. You said its gets stuck on Setting up database section. ANy logs around that, before it for example, that might be interesting? Might help if you share the logs related to it. @miho played more with Supabase so let's also see if he has some ideas!
AibohpDealer54
AibohpDealer545mo ago
Thank you so much!! I will check out the link right after I answer your questions! 1) I actually uninstalled docker bc it was taking up like 100 smtg GB, so wasp start db shouldn't be running in another terminal 2) This is my supabase url: postgres://postgres.username:[email protected]:6543/postgres 3) In supabase I did get one error message, however I don't have the most experience with supabase so I was unsure. The error message that I got was
prepared statement "sl" already exists
prepared statement "sl" already exists
I don't have the most experience in Supabase, so do I need to set anything up in supabase before hand or create any tables or anything? I believe that it is running and live. If you think its possible i'm missing any step no matter how small please let me know as I might've missed that step
martinsos
martinsos5mo ago
Unfortauntely I also don't have :), haven't personally played with Supabase -> some other team members have, I pinged them so let's see what they say. They are out for conference at the moment so it might take a bit, but they will get to it! I would proably look into Supabase docs for Prisma: https://supabase.com/partners/integrations/prisma -> those should mostly be a match for Wasp -> but I haven't checked them thorougly enough to say if there is something redundant there at the moment.
AibohpDealer54
AibohpDealer545mo ago
Thank you!! I will check it out
martinsos
martinsos5mo ago
I am just looking at https://github.com/wasp-lang/lazy-card-generator -> the env vars @miho set there are related to supabase are DATABASE_URL, SUPABASE_CARDS_BUCKET, SUPABASE_KEY, SUPABASE_PROJECT_URL. However he was also using their blog storage, so I think the last three are for that, meaning that most likely just DATABASE_URL should be enough.
AibohpDealer54
AibohpDealer545mo ago
Thank you so much for sending this link!! I got it to work! The issue was that I was running it using the transaction mode instead of the session mode one way to tell is by looking at the port numbers
postgres://postgres.username:[email protected]:6543/postgres
postgres://postgres.username:[email protected]:6543/postgres
here it was 6543 while it should've been 5432
martinsos
martinsos5mo ago
Oh ok interesting! So you were running Supabase in transaction mode instad of the session mode. Was transaction mode default? No worries if you don't have the capacity, but if you do, what would be cool is if you opened an issue on our Github called "Using Supabase" and write short instrutions on how you did it + tips / warnings. Then we can use that to make a page in the docs for other users!
AibohpDealer54
AibohpDealer544mo ago
Hey i'm so sorry I missed this message
MEE6
MEE64mo ago
Wohooo @AibohpDealer54, you just became a Waspeteer level 2!
AibohpDealer54
AibohpDealer544mo ago
Yes I would love to do that, however I am not that well versed with github could you show me how to do that sometime?
martinsos
martinsos4mo ago
Writing issue on Github is super easy, just go here https://github.com/wasp-lang/wasp/issues/new and type title and description!
Want results from more Discord servers?
Add your server