Handling errors for large-scaled applications
Answered
Netherland Dwarf posted this in #help-forum
Netherland DwarfOP
I have a question, so I'm trying to code a SaaS and I'm curious how others handle errors in SSR. Now, I'm not curious on exactly how to handle it but more so what to do.
This snippet just gets the user logged in, database instance, and the notifications associated with the user
is it common practice to add extra error checks especially if this is going to be used by thousand of users, or is typical error handling (like try/catch or default SSR behavior) usually enough to ensure it works reliably for most users? I'm curious because the fact it'll be used by many people, makes me question whether that alone will suffice.
This is somewhat how the rest of my code looks, so I'm trying to apply whatever I get to the others
Or like another:
This snippet just gets the user logged in, database instance, and the notifications associated with the user
export async function Notifications() {
const { supabase, user } = await getDashboardContext(undefined);
const notifications = await getNotifications(supabase, user)
...
is it common practice to add extra error checks especially if this is going to be used by thousand of users, or is typical error handling (like try/catch or default SSR behavior) usually enough to ensure it works reliably for most users? I'm curious because the fact it'll be used by many people, makes me question whether that alone will suffice.
This is somewhat how the rest of my code looks, so I'm trying to apply whatever I get to the others
Or like another:
const params = await props.params;
const sport = getProfileSport(params.sport)
const { supabase, user, profile } = await getDashboardContext(sport.sport);
const conversation = await getConversation(supabase, user, params.conversation, profile.id)
const recentMessage = await getRecentConversationMessage(supabase, conversation.id)
...
13 Replies
but u really need to be careful what checks are good and what not
something will always not work so just make sure u dont spam errors checks
@gin yes it is common practice
Netherland DwarfOP
Would just having an error boundary for routes suffice?
u could build a custom fetch hook that handles errors
or just use swr
Netherland DwarfOP
I looked at some vercel examples and noticed that a lot don’t really have much error checks but they do throw errors and I’m assuming that is gets catached on the error.js
so far i know
it doesnt handle errors by route handlers
Netherland DwarfOP
Fetching almost everything on the server so not sure if SWR would help
@gin it doesnt handle errors by route handlers
Netherland DwarfOP
Oh okay
Alright then, thanks