slower session lookup in prod than local

not sure if anyone else has encountered this issue (next-auth stable v4) but it's weird to see that calling /session locally takes 30-40ms (pic 1) but on production it goes up to 400-500ms (pic 2) (which I think is because it's not cached? not using the provider?) I'm attaching screenshots and my root layout.tsx Note: I'm NOT using a local db on local dev, both instances are connecteed to planetscale through regular connection strings
No description
No description
2 Replies
Liltripple_reid
Liltripple_reid10mo ago
the layout.tsx
// Default created by T3
import "~/styles/globals.css";

import { GeistMono } from "geist/font/mono";
import { GeistSans } from "geist/font/sans";
import { AuthProvider } from "~/components/auth-provider";
import { TRPCReactProvider } from "~/trpc/react";

export const metadata = {
title: "Create T3 App",
description: "Generated by create-t3-app",
icons: [{ rel: "icon", url: "/favicon.ico" }],
};

export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body className={`font-sans ${GeistSans.variable} ${GeistMono.variable}`}>
<AuthProvider>
<TRPCReactProvider>{children}</TRPCReactProvider>
</AuthProvider>
</body>
</html>
);
}
// Default created by T3
import "~/styles/globals.css";

import { GeistMono } from "geist/font/mono";
import { GeistSans } from "geist/font/sans";
import { AuthProvider } from "~/components/auth-provider";
import { TRPCReactProvider } from "~/trpc/react";

export const metadata = {
title: "Create T3 App",
description: "Generated by create-t3-app",
icons: [{ rel: "icon", url: "/favicon.ico" }],
};

export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body className={`font-sans ${GeistSans.variable} ${GeistMono.variable}`}>
<AuthProvider>
<TRPCReactProvider>{children}</TRPCReactProvider>
</AuthProvider>
</body>
</html>
);
}
the AuthProvider
"use client";

import { SessionProvider } from "next-auth/react";
import { type ReactNode } from "react";

export const AuthProvider = ({ children }: { children: ReactNode }) => {
return <SessionProvider>{children}</SessionProvider>;
};
"use client";

import { SessionProvider } from "next-auth/react";
import { type ReactNode } from "react";

export const AuthProvider = ({ children }: { children: ReactNode }) => {
return <SessionProvider>{children}</SessionProvider>;
};
Alky
Alky10mo ago
There's a few things you can check: 1 - Network issue: check if your deployment is in the same region as your database. When in dev mode, your client and server are the same, so, its your machine -> db -> your machine. When in prod, its your machine -> server > db -> server -> your machine. 2 - Execution issue: log the execution time of the login logic and check the log on the server. 3 - Build issue(?): Build your project locally and test the built version of it
Want results from more Discord servers?
Add your server