File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,13 @@ export async function authHook(
2020 // Check if database is configured before attempting authentication
2121 const dbStatus = getDbStatus ( ) ;
2222 if ( ! dbStatus . configured || ! dbStatus . initialized ) {
23- // Database not ready, skip authentication
23+ // Database not ready, skip authentication - log this for debugging
24+ request . log . warn ( {
25+ operation : 'auth_hook' ,
26+ dbConfigured : dbStatus . configured ,
27+ dbInitialized : dbStatus . initialized ,
28+ dialect : dbStatus . dialect
29+ } , 'Auth hook: Database not ready, skipping authentication' ) ;
2430 request . user = null ;
2531 request . session = null ;
2632 return ;
Original file line number Diff line number Diff line change @@ -748,6 +748,20 @@ export const createServer = async () => {
748748 }
749749 }
750750 } ) ;
751-
751+
752+ // Verify database is ready before allowing server to accept requests
753+ // This prevents workers from accepting requests before database is initialized
754+ const finalDbStatus = getDbStatus ( ) ;
755+ if ( ! finalDbStatus . configured || ! finalDbStatus . initialized ) {
756+ server . log . error ( {
757+ operation : 'startup_check' ,
758+ dbConfigured : finalDbStatus . configured ,
759+ dbInitialized : finalDbStatus . initialized ,
760+ dialect : finalDbStatus . dialect
761+ } , 'Database not ready at startup - refusing to start server' ) ;
762+ process . exit ( 1 ) ;
763+ }
764+ server . log . info ( 'Database ready, server initialization complete' ) ;
765+
752766 return server ;
753767}
You can’t perform that action at this time.
0 commit comments