Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Request Timeout Logs Unnecessary Errors to Console #1437

Closed
mdaneri opened this issue Oct 26, 2024 · 0 comments · Fixed by #1438
Closed

HTTP Request Timeout Logs Unnecessary Errors to Console #1437

mdaneri opened this issue Oct 26, 2024 · 0 comments · Fixed by #1438
Labels
Milestone

Comments

@mdaneri
Copy link
Contributor

mdaneri commented Oct 26, 2024

Description:
When an HTTP request times out in Pode, an error message is unnecessarily written to the console, even though the timeout is expected behavior. This results in a cluttered log output, making it harder to identify genuine issues.

Steps to Reproduce:

  1. Trigger an HTTP request that will exceed the timeout threshold.
  2. Observe the console/logs for error messages.

Expected Behavior:
Timeouts should not be logged as errors unless there is an unexpected issue related to the timeout.

Actual Behavior:
An error message appears on the console each time an HTTP request times out, despite this being an expected event.

Fix Implemented:
Modified the PodeSocket.HandleContext method to prevent logging HTTP request timeout errors:

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;
}

The addition of the condition !httpRequestException.Message.StartsWith("Request timeout") ensures that only non-timeout-related exceptions are logged, reducing unnecessary console output.

@mdaneri mdaneri changed the title Pode Listener write on console multiple [Error] HttpRequestException: Request timeout HTTP Request Timeout Logs Unnecessary Errors to Console Oct 26, 2024
@Badgerati Badgerati added this to the 2.11.1 milestone Oct 28, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in 🚀 Pode Roadmap Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants