Skip to content

Commit d19fd0d

Browse files
committed
session取得時のエラーハンドリング
1 parent 5e55768 commit d19fd0d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

app/accountMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function AccountMenu() {
4242
}
4343
};
4444

45-
if (isPending) {
45+
if (isPending || !session) {
4646
return <div className="w-10 h-10 skeleton rounded-full"></div>;
4747
}
4848

app/lib/chatHistory.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ async function initAll(ctx?: Partial<Context>): Promise<Context> {
3737
ctx.auth = await getAuthServer(ctx.drizzle);
3838
}
3939
if (!ctx.userId) {
40-
const session = await ctx.auth.api.getSession({
41-
headers: await headers(),
42-
});
43-
if (session) {
44-
ctx.userId = session.user.id;
40+
try {
41+
const session = await ctx.auth.api.getSession({
42+
headers: await headers(),
43+
});
44+
if (session) {
45+
ctx.userId = session.user.id;
46+
}
47+
} catch (e) {
48+
console.error("Failed to get session in initAll:", e);
4549
}
4650
}
4751
return ctx as Context;

0 commit comments

Comments
 (0)