better logs
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user