better logs

This commit is contained in:
2026-07-21 16:56:41 -05:00
parent 0755fb9d78
commit 8731cc0307
+11
View File
@@ -447,5 +447,16 @@ export function createProxyApp({ keys, keyRotator = createKeyRotator(keys), fetc
}
});
// `express.json()` reports a client that closes its upload stream as a
// `request.aborted` error. At that point there is no client left to send a
// response to, so prevent Express's default error handler from printing a
// misleading stack trace for an expected disconnect.
app.use((error, request, response, next) => {
if (error?.type !== 'request.aborted') return next(error);
response.statusCode = 499; // Conventional internal status for client-closed requests.
console.warn(`Client disconnected while uploading request body: ${request.method} ${request.originalUrl} from ${clientIp(request)}`);
});
return app;
}