Skip to content

Commit 7d2d9b2

Browse files
fix google login issues
1 parent 31608f8 commit 7d2d9b2

3 files changed

Lines changed: 34 additions & 6 deletions

File tree

server/src/database/db.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,26 @@ const connectionString = process.env["DATABASE_URL"] ?? "";
55

66
// Pool size: Neon/Supabase free tiers allow ~20 connections.
77
// Keep a comfortable margin below the hard limit.
8-
const adapter = new PrismaPg({
9-
connectionString,
10-
max: 10, // max pool connections
11-
idleTimeoutMillis: 30_000, // release idle connections after 30 s
12-
connectionTimeoutMillis: 5_000, // fail fast instead of hanging
13-
});
8+
const adapter = new PrismaPg(
9+
{
10+
connectionString,
11+
max: 10,
12+
idleTimeoutMillis: 30_000,
13+
connectionTimeoutMillis: 5_000,
14+
keepAlive: true,
15+
},
16+
{
17+
// Without these, an idle pg client erroring (managed Postgres dropping
18+
// idle TCP connections, network blips) emits an unhandled 'error' event
19+
// on the pool and crashes the Node process.
20+
onPoolError: (err) => {
21+
console.error("[prisma/pg] pool error:", err);
22+
},
23+
onConnectionError: (err) => {
24+
console.error("[prisma/pg] connection error:", err);
25+
},
26+
},
27+
);
1428

1529
const globalForPrisma = global as unknown as { prisma: PrismaClient };
1630

server/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ for (const key of REQUIRED_ENV) {
7878
const __filename = fileURLToPath(import.meta.url);
7979
const __dirname = path.dirname(__filename);
8080

81+
process.on("unhandledRejection", (reason) => {
82+
console.error("[process] unhandledRejection:", reason);
83+
});
84+
process.on("uncaughtException", (err) => {
85+
console.error("[process] uncaughtException:", err);
86+
});
87+
8188
const app = express();
8289
app.set("trust proxy", 1);
8390
const PORT = process.env["PORT"] || 3000;

server/src/module/auth/auth.controller.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ export class AuthController {
6464
role?: string;
6565
};
6666
if (!credential && !accessToken) {
67+
console.warn("[auth/google] empty body", {
68+
contentType: req.headers["content-type"],
69+
contentLength: req.headers["content-length"],
70+
bodyType: typeof req.body,
71+
bodyKeys: req.body && typeof req.body === "object" ? Object.keys(req.body) : null,
72+
rawBody: req.body,
73+
});
6774
return res.status(400).json({ message: "Google credential is required" });
6875
}
6976

0 commit comments

Comments
 (0)