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

Chapter 6: Setting up your database - Error [object Object] #833

Open
matt-halden opened this issue Aug 14, 2024 · 9 comments
Open

Chapter 6: Setting up your database - Error [object Object] #833

matt-halden opened this issue Aug 14, 2024 · 9 comments

Comments

@matt-halden
Copy link

matt-halden commented Aug 14, 2024

Hi, I am on my second round of doing this next.js tutorial from scratch in an attempt to seed the postgres database correctly, but I just cannot figure out why I am non de-script errors (Error: [object Object]), even when on my first try I tried to log everything on my first go around. Please help!

I am pasting a screenshot of my browser errors and linking my current repo if anyone is willing to take a look. I read many other posts on chapter 6 errors, correctly commented out my route.ts ("uncomment this file..."), compared with a friend who got it working (but, looks like his route.ts file was different from a few months ago), see no logs anywhere in Vercel, etc. I confirm I correctly pasted over the env variables into my .env file. I got an error trying to install bcryptjs to see if that was somehow the error that Vercel recommends to check. Let me know if there is anything I can try, I am very confused.

Screenshot 2024-08-14 at 9 33 17 AM

Repo: https://github.com/pyMasta/nextjs-v3

@matt-halden
Copy link
Author

Well, it looks like somebody else had the same error that i miss, and it works if you run /seed on your deployed environment, not local like the instructions have: #792

However, I am not sure if this is the way Vercel does want you to do this or if they just have not updated the tutorial.

@SiyabongaMat
Copy link

I get the exact same error. This is my fourth rerun of the project tutorial 😓

@matt-halden
Copy link
Author

matt-halden commented Aug 14, 2024

I hear you. I just got it working, saw the data, and now Vercel errors saying "Failed to fetch tables in your database" and the data is gone :/

@SiyabongaMat
Copy link

SiyabongaMat commented Aug 14, 2024

Does the error say: 'error fetching card data' and shows that the error is in the fetchInvoices method?

@SiyabongaMat
Copy link

I figured something out. It worked finally.
What I did: I changed the region of the postgres database to frankfurt germany. It is more in line with my timezone.
Also, there is a step that I missed. Its so small its easy to miss it. Just after telling you to create a postgres database and connecting it to you project it subtly tells you to install the vercel/postgres sdk with this line:

Finally, run pnpm i @vercel/postgres in your terminal to install the Vercel Postgres SDK

In my other attempts, when I checked my package.json file for dependancies, I always thought there was no need to install the vercel/postgres sdk because I thought it was already installed, but turns out you need to install the sdk.

Hope this helps 😁👍

@akkshayTandon
Copy link

@SiyabongaMat Hey, glad to hear that you resolved issue on your own. I think it should be removed.

@KinonoChen
Copy link

I figured something out. It worked finally. What I did: I changed the region of the postgres database to frankfurt germany. It is more in line with my timezone. Also, there is a step that I missed. Its so small its easy to miss it. Just after telling you to create a postgres database and connecting it to you project it subtly tells you to install the vercel/postgres sdk with this line:

Finally, run pnpm i @vercel/postgres in your terminal to install the Vercel Postgres SDK

In my other attempts, when I checked my package.json file for dependancies, I always thought there was no need to install the vercel/postgres sdk because I thought it was already installed, but turns out you need to install the sdk.

Hope this helps 😁👍

Hi, I was wondering if you ended up successfully seeding locally?I'm having this problem: I can successfully seed an application that I deployed on vercel, but it keeps failing to seed locally, maybe vercel doesn't support local connections to vercel/postgres?

@BrettHoyer
Copy link

BrettHoyer commented Sep 26, 2024

@KinonoChen Instead of using @vercel/postgres, I used the node-postgres package and rewrote the seed file to use its syntax. The changes were fairly minimal. This allowed me to connect to a Postgres database running on my machine in Docker for testing. Hope this helps.

@SteaneMurphy
Copy link

The issue as far as I can tell is that the Washington default server causes a latency that lags out the request. If you are using the "@vercel/postgres" package to connect to their cloud database, it might work better if you delete the database, re-create the database, and select a server close to your geographic location.

One of the ways I confirmed this was the issue:

  • used the cloud deployed site with the /seed endpoint, this successfully seeded the database (Washington server)
  • created a new database with a geographically close server to me, this also worked from the deployed /seed endpoint (Closer server)
  • the new database also worked locally when using the local /seed endpoint (Closer server)

Without looking into the specific code that is a part of the Vercel postgres package, I am going to assume that the request is timing out (read: unresolved promise) due to geographic location. This issue should be fixed if someone from Vercel ever has 20 minutes to fix this.

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

No branches or pull requests

6 participants