Skip to content

Confusing message on Http timeout #67505

Closed

Description

@danmoseley

From some test failures I noticed:

NuGet.Protocol.Core.Types.FatalProtocolException : An error occurred while retrieving package metadata for 'Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.2' from source 'dotnet-public'.
---- System.Threading.Tasks.TaskCanceledException : The request was canceled due to the configured HttpClient.Timeout of -0.001 seconds elapsing.
-------- System.TimeoutException : The operation was canceled.
------------ System.Threading.Tasks.TaskCanceledException : The operation was canceled.
---------------- System.TimeoutException : A connection could not be established within the configured ConnectTimeout.

Apparently the timeout was set to Timeout.InfiniteTimeSpan, which is -1 ms. Presumably this couldn't have expired, so the message is confusing. I don't have a repro, so feel free to close if it's not important.

Activity

  1. ghost added
    untriaged
    on Apr 3, 2022
  2. danmoseley commented on Apr 3, 2022

    @danmoseley
    ContributorAuthor
  3. MihaZupan commented on Apr 3, 2022

    @MihaZupan
    Member

    The relevant code path that determines the exception type:

    // If this exception is for cancellation, but cancellation wasn't requested, either by the caller's token or by the pending requests source,
    // the only other cause could be a timeout. Treat it as such.
    e = toThrow = new TaskCanceledException(SR.Format(SR.net_http_request_timedout, _timeout.TotalSeconds), new TimeoutException(e.Message, e), oce.CancellationToken);

    We should differentiate between a regular timeout and the ConnectTimeout.

    Ideally, we would also expose such info in a programmatical way to the user. This recently came up in YARP as well (dotnet/yarp#1628).

  4. karelz commented on Apr 7, 2022

    @karelz
    Member

    Triage: It seems we are doing the right thing in the ConnectionPool, but HttpClient overrides it (and wraps with TImeoutException even if the timeout is not set) -- we should fix that.

  5. added this to the 7.0.0 milestone on Apr 7, 2022
  6. removed
    untriaged
    on Apr 7, 2022
  7. self-assigned this
    on Jul 15, 2022
  8. ghost added
    in-pr
    on Jul 15, 2022
  9. ghost removed
    in-pr
    on Jul 19, 2022
  10. ghost locked as resolved and limited conversation to collaborators on Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions