File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
1529const globalForPrisma = global as unknown as { prisma : PrismaClient } ;
1630
Original file line number Diff line number Diff line change @@ -78,6 +78,13 @@ for (const key of REQUIRED_ENV) {
7878const __filename = fileURLToPath ( import . meta. url ) ;
7979const __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+
8188const app = express ( ) ;
8289app . set ( "trust proxy" , 1 ) ;
8390const PORT = process . env [ "PORT" ] || 3000 ;
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments