@@ -15,6 +15,7 @@ const __dirname = fileURLToPath(new URL('.', import.meta.url));
1515const PORT = process . env . PORT || 3030 ;
1616const HOST = process . env . HOST || '0.0.0.0' ;
1717const REQUEST_TIMEOUT = 60 * 1000 ; // 60s timeout for requests
18+ const COMMIT_SHA = process . env . COMMIT_SHA || 'unknown' ;
1819
1920// Configure global fetch with connection pooling for much better performance
2021// Without this, every fetch creates a new TCP connection (DNS + handshake overhead)
@@ -110,7 +111,7 @@ const server = createServer(async (req, res) => {
110111
111112 // Set request timeout
112113 req . setTimeout ( REQUEST_TIMEOUT , ( ) => {
113- console . error ( `⏱️ Request timeout (${ REQUEST_TIMEOUT } ms): ${ req . method } ${ req . url } [${ requestId } ]` ) ;
114+ console . error ( `⏱️ Request timeout (${ REQUEST_TIMEOUT } ms): ${ req . method } ${ req . url } [${ requestId } ] [commitSha: ${ COMMIT_SHA } ] ` ) ;
114115 if ( ! res . headersSent ) {
115116 res . writeHead ( 408 , { 'Content-Type' : 'text/plain' } ) ;
116117 res . end ( 'Request Timeout' ) ;
@@ -140,7 +141,7 @@ const server = createServer(async (req, res) => {
140141 // Log response for static files
141142 try {
142143 const latency = Date . now ( ) - requestStart ;
143- logResponse ( method , pathname , requestId , latency , 200 ) ;
144+ logResponse ( method , pathname , requestId , latency , 200 , COMMIT_SHA ) ;
144145 } catch ( err ) {
145146 console . error ( `Response logging error [${ requestId } ]:` , err ) ;
146147 }
@@ -177,9 +178,9 @@ const server = createServer(async (req, res) => {
177178
178179 // Log slow SSR requests
179180 if ( ssrTime > 2000 ) {
180- console . debug ( `🔥 VERY SLOW SSR: ${ req . method } ${ pathname } took ${ ssrTime } ms [${ requestId } ]` ) ;
181+ console . debug ( `🔥 VERY SLOW SSR: ${ req . method } ${ pathname } took ${ ssrTime } ms [${ requestId } ] [commitSha: ${ COMMIT_SHA } ] ` ) ;
181182 } else if ( ssrTime > 1000 ) {
182- console . debug ( `⚠️ SLOW SSR: ${ req . method } ${ pathname } took ${ ssrTime } ms [${ requestId } ]` ) ;
183+ console . debug ( `⚠️ SLOW SSR: ${ req . method } ${ pathname } took ${ ssrTime } ms [${ requestId } ] [commitSha: ${ COMMIT_SHA } ] ` ) ;
183184 }
184185
185186 // Convert Web Standard Response to Node.js response
@@ -270,7 +271,7 @@ const server = createServer(async (req, res) => {
270271 // Log response after sending
271272 try {
272273 const latency = Date . now ( ) - requestStart ;
273- logResponse ( method , pathname , requestId , latency , res . statusCode ) ;
274+ logResponse ( method , pathname , requestId , latency , res . statusCode , COMMIT_SHA ) ;
274275 } catch ( err ) {
275276 console . error ( `Response logging error [${ requestId } ]:` , err ) ;
276277 }
@@ -284,7 +285,7 @@ const server = createServer(async (req, res) => {
284285 // Log error response
285286 try {
286287 const latency = Date . now ( ) - requestStart ;
287- logResponse ( method , pathname , requestId , latency , res . statusCode || 500 ) ;
288+ logResponse ( method , pathname , requestId , latency , res . statusCode || 500 , COMMIT_SHA ) ;
288289 } catch ( err ) {
289290 console . error ( `Error response logging error [${ requestId } ]:` , err ) ;
290291 }
0 commit comments