Description:
This pull request addresses issue #1437, where unnecessary error messages were being logged to the console when HTTP requests timed out. The current behavior resulted in cluttered logs, making it difficult to differentiate between expected timeouts and actual errors that require attention.
Changes Made:
Fix for Error Logging on Request Timeout:
Updated the PodeSocket.HandleContext method to add a condition that prevents logging exceptions for HTTP request timeouts.
Specifically, modified the context.CloseImmediately block to check if the exception is an HttpRequestException with a message starting with "Request timeout". If so, the error is no longer logged, as this is expected behavior.
Code Snippet:
if (context.CloseImmediately)
{
// Check if the error is not an HttpRequestException with a message starting with "Request timeout".
if (!(context.Request.Error is HttpRequestException httpRequestException) || !httpRequestException.Message.StartsWith("Request timeout"))
{
PodeHelpers.WriteException(context.Request.Error, Listener);
}
context.Dispose(true);
process = false;
}
Code Improvements:
Comments and Headers: Added comprehensive comments and XML documentation headers to the following files for better code readability and maintainability:
PodeSocket.cs
PodeRequest.cs
PodeContext.cs
Additional Logs: Introduced additional logging to provide better insights into key actions and errors during socket, request, and context handling.
Optimizations: Made several small optimizations to improve the performance and stability of socket and context handling.
Impact:
This change reduces unnecessary console output for expected request timeouts, leading to cleaner logs.
Improved code readability with added documentation and comments.
Only unexpected or non-timeout-related exceptions will be logged, improving the maintainability of logs and making it easier to detect real issues.
Added logs and optimizations contribute to easier debugging and better performance.
Linked Issue: #1437 - HTTP Request Timeout Logs Unnecessary Errors to Console
Description: This pull request addresses issue #1437, where unnecessary error messages were being logged to the console when HTTP requests timed out. The current behavior resulted in cluttered logs, making it difficult to differentiate between expected timeouts and actual errors that require attention.
Changes Made:
Fix for Error Logging on Request Timeout:
PodeSocket.HandleContext
method to add a condition that prevents logging exceptions for HTTP request timeouts.context.CloseImmediately
block to check if the exception is anHttpRequestException
with a message starting with "Request timeout". If so, the error is no longer logged, as this is expected behavior.Code Snippet:
Code Improvements:
PodeSocket.cs
PodeRequest.cs
PodeContext.cs
Impact: