Ben
Explore posts from serversTTCTheo's Typesafe Cult
•Created by Ben on 10/15/2024 in #questions
tRPC query eating all DB connections upon window refresh
2 replies
TTCTheo's Typesafe Cult
•Created by Ben on 10/3/2024 in #questions
Max Connection Issue with Supabase + Vercel
I am running into max connection issues when I am using supabase within an application hosted in a serverless environment (vercel).
I've done everything I can find by the docs, but if I have a spike of 300+ users on my app at once, I start to run into a lot of max connection errors.
I am using trpc to help batch request and limit connections made. I create the postgres connection outside of drizzle, set max connections to 3, and pass the instance in.
I am using transaction mode in supabase so it uses supavisor.
I have prepared statements set to false.
Does anyone have any advice that might be harder to come by? Our team is considering swapping to a persistent server because we're running out of options as we're scaling quickly and keep running into connection issues w/ Supabase.
Thanks for any help!
12 replies
TTCTheo's Typesafe Cult
•Created by Ben on 9/10/2024 in #questions
ReactHookForm propagating nested forms despite e.stopPropagation
So I have a RHF inside a RHF, I know this isn't best practice, but this SO thread suggests it's possible: https://github.com/react-hook-form/react-hook-form/issues/1005#issuecomment-626050339
Code looks like:
This is nested inside another RHF.
Despite the console.log("here") printing, the event is still being propagated to the parent form when I don't want it to be.
Another approached I tried was removing the "submit" type from the button, and just having the button itself call the onSubmit, still didn't work :BabyRage:
1 replies
TTCTheo's Typesafe Cult
•Created by Ben on 6/3/2024 in #questions
Does saving files incur a cost on Vercel?
So I need to chunk out large audio files(20-50mb) that are uploaded to my website, and break those out into 10 min chunks. I wrote the following snippet to do that
This runs fine locally, my only concern is I'm not sure what costs look like for saving files to the temp folder in vercel, and couldn't really find info on the pricing page? Am I randomly gonna get hit with a $1000 bill? Files get immediately deleted at the end of the API call if that matters.
12 replies
TTCTheo's Typesafe Cult
•Created by Ben on 5/14/2024 in #questions
Prisma Migrate Diff coming back when it shouldn't
3 replies
PPrisma
•Created by Ben on 5/14/2024 in #help-and-questions
Prisma Migrate Diff coming back when it shouldn't
3 replies
TTCTheo's Typesafe Cult
•Created by Ben on 5/12/2024 in #questions
Weird Clerk behavior(user is null) with new API
21 replies
TTCTheo's Typesafe Cult
•Created by Ben on 4/24/2024 in #questions
Uploadthing Image not showing up
6 replies
TTCTheo's Typesafe Cult
•Created by Ben on 4/12/2024 in #questions
Prisma/tRPC query failing 1/2 the time, but only in Prod
11 replies
TTCTheo's Typesafe Cult
•Created by Ben on 4/10/2024 in #questions
Best way to handle fetching large amounts of emails
So I have a T3 app that is essentially a project manager for a construction/remodel company. Every time the company is starting a project on a client's house, they create a new "project' in our app. One of the features for the scope is to have an "email" tab where we use the gmail API to fetch every conversation an employee of the company has had with the client, and display them in the app.
The gmail API for orgs does have an endpoint to fetch all emails built in, but based on the fact that my fetch for single users emails takes like 3-5 seconds ATM, I'm guessing that doing a fetch on all this data at runtime is not going to to be viable.
What approach would you guys recommend? One approach one of my coworkers floated was to essentially have a separate server that's running 24/7, and does this fetch call once every minute. We then have a DB that essentially just has one table, customers, and each customer has an array of messageIds. All we do is add in add in the ID of any message that has happened since the last fetch to the array. Then on the main app, we fetch the list of messageIds from the DB for the customer, and use that pre-compiled list of messages to fetch each email needed.
Another similar approach would be that whenever an "admin" logs in on the app, and opens a project, we do a fetch for their conversations with the given client, then push that to the main DB we already have. Then we can fetch everyone's previous convos. Downside to this approach is that the emails would only be updated when one of the admin logs in and views the projects, so recent emails could take a while to come, users don't have a way of knowing if the list of emails their looking at is stale or not.
Curious to hear thoughts about better approaches as I'm not really a big fan of either of these!
5 replies
TTCTheo's Typesafe Cult
•Created by Ben on 8/21/2023 in #questions
Best way to fetch a range of items
So I’m creating a game using T3+Planetscale where players get a score, I’m currently working on the leaderboard component, where after a player gets a Score, their score is displayed something like:
person 1: 3.456
person 2: 3.768
Person 3 :4.523
Current Player:4.789
person 4 :5.123
etc...
Basically I need to fetch the 3 players with scores lower/higher than the current score. Not sure how to do that without fetching all the scores. Obviously brute force would be to fetch all the scores and do this client side which is easy, but once their are tons of scores this will lead to a stupid amount of row reads. Any way to write a Prisma query to get around this?
5 replies
TTCTheo's Typesafe Cult
•Created by Ben on 6/14/2023 in #questions
Invalid `prisma.product.findMany()` invocation
So I was working on some filtering on a query for my Prisma DB and managed to bork the DB. Not sure what's going on. This is the error message:
The weird thing is that another person is working on a ssperate branches of this project, also just started getting this issue an hour or two ago. Both of our branches were working fine earlier today, and at the point they got forked. You'd think it's a problem with our DB or something, but we're both using local DB's...
2 replies
TTCTheo's Typesafe Cult
•Created by Ben on 6/8/2023 in #questions
Vercel deployment issue with uploadthing
6 replies
TTCTheo's Typesafe Cult
•Created by Ben on 1/26/2023 in #questions
Multiple renders of the same chat sent via Pusher
13 replies
TTCTheo's Typesafe Cult
•Created by Ben on 1/18/2023 in #questions
tRPC complaining about unsafe assignment of any on mutation
12 replies
TTCTheo's Typesafe Cult
•Created by Ben on 1/5/2023 in #questions
env Variables causing issue deploying to Vercel
11 replies
TTCTheo's Typesafe Cult
•Created by Ben on 12/12/2022 in #questions
Image Fetching bug with NextJS
So I'm trying to load in a set of profile pictures for a list of contributors to a repo. I have a list of everyone's github handle's. I'm fetching the profile pictures like so
Their are a few github handle's that were submitted incorrectly, so I'm trying to replace those images with a default thumbnail using the onError callback:
If I don't refresh the page for a few minutes, and then refresh the page, everything works as expected. But if I refresh right afterwards , the fallbackImg gets replaced with the deafult 404 img. Even weirder, I can right click on the missing img, select "load image" and the image loads in properly.
Any clue what's going on here?
9 replies
TTCTheo's Typesafe Cult
•Created by Ben on 11/17/2022 in #questions
Trying to get TailwindCSS working with Next13
42 replies
TTCTheo's Typesafe Cult
•Created by Ben on 11/15/2022 in #questions
Not able to console.log in NextJS 13
43 replies
TTCTheo's Typesafe Cult
•Created by Ben on 9/19/2022 in #questions
Optimistic updates not working tRPC useQuery
78 replies