async-rs / async-rs/async-std

FutureExt::timeout panics on Duration::MAX

Open
#979 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
4.1k
Forks
339
PR merge metrics
No merged PRs in 30d

Description

Ahoj!

This:
```
async_std::future::pending::<()>()
.timeout(Duration::MAX)
.await?;
```

Panics:
> thread 'main' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:374:33

Proposal: use some form of saturating or checked add.

Many thanks, Yo

Trace:
> 0: rust_begin_unwind
> at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:493:5
> 1: core::panicking::panic_fmt
> at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/panicking.rs:92:14
> 2: core::option::expect_failed
> at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/option.rs:1241:5
> 3: core::option::Option::expect
> at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/option.rs:349:21
> 4: >::add
> at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/time.rs:374:9
> 5: async_io::Timer::after
> at /home/robert/.cargo/registry/src/github.com-1ecc6299db9ec823/async-io-1.6.0/src/lib.rs:158:19
> 6: async_std::utils::timer_after
> at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.9.0/src/utils.rs:72:5
> 7: async_std::future::timeout::TimeoutFuture::new
> at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.9.0/src/future/timeout.rs:54:20
> 8: async_std::future::future::FutureExt::timeout
> at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.9.0/src/future/future/mod.rs:393:13
> 9: samotop_server::main_fut::{{closure}}
> at ./src/main.rs:136:5

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.