Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(web): handle unhandled promise rejection from authClient.getSession()

(justin)randoneering494f1fbc9029
diff --git a/apps/web/src/routes/_layout/_authenticated.tsx b/apps/web/src/routes/_layout/_authenticated.tsx
index 05da1002a..d9cc218dc 100644
--- a/apps/web/src/routes/_layout/_authenticated.tsx
+++ b/apps/web/src/routes/_layout/_authenticated.tsx
@@ -4,7 +4,13 @@ import { authClient } from "@/lib/auth-client";
// protects all child routes, must be logged in
export const Route = createFileRoute("/_layout/_authenticated")({
beforeLoad: async ({ location }) => {
- const { data: session } = await authClient.getSession();
+ let session = null;
+ try {
+ const { data } = await authClient.getSession();
+ session = data;
+ } catch {
+ // getSession() rejected (e.g. network error) — treat as unauthenticated
+ }
if (!session) {
throw redirect({
to: "/auth/sign-in",
diff --git a/apps/web/src/routes/auth.tsx b/apps/web/src/routes/auth.tsx
index f64de56de..7c56b4d87 100644
--- a/apps/web/src/routes/auth.tsx
+++ b/apps/web/src/routes/auth.tsx
@@ -3,7 +3,13 @@ import { authClient } from "@/lib/auth-client";
export const Route = createFileRoute("/auth")({
beforeLoad: async () => {
- const { data: session } = await authClient.getSession();
+ let session = null;
+ try {
+ const { data } = await authClient.getSession();
+ session = data;
+ } catch {
+ // getSession() rejected — treat as unauthenticated, allow auth pages to render
+ }
if (session) {
throw redirect({
to: "/dashboard",