Skip to content

Err(Timeout(Global)) can be returned even when no timeouts are set #1024

@al13n321

Description

@al13n321

https://docs.rs/ureq/3.0.0-rc4/ureq/enum.Error.html#variant.Timeout says:

By default no timeouts are set, which means this error can’t happen.

But it can. E.g. in src/unversioned/transport/tcp.rs:

    let maybe_stream = if let Some(when) = timeout.not_zero() {
        TcpStream::connect_timeout(&addr, *when)
    } else {
        TcpStream::connect(addr)
    }
    .normalize_would_block();

    let stream = match maybe_stream {
        Ok(v) => v,
        Err(e) if e.kind() == io::ErrorKind::TimedOut => {
            return Err(Error::Timeout(timeout.reason))
        }
        Err(e) => return Err(e.into()),
    };

I.e. if the OS-dependent socket implementation returned ErrorKind::TimedOut after some environment-dependent timeout, ureq translates it to Error::Timeout(something) regardless of the configured timeouts.

In my test it returned Timeout(Global) (because timeout had reason = Global, I guess because it's the default when no timeouts are set?). That's particularly confusing because I would expect the global timeout to be a ureq-level concept, the least platform- or environment-dependent of all timeouts.

A guess at what to change (I'm not familiar with ureq, feel free to ignore):

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions