Skip to content

Surface invalid async sleep durations instead of discarding timer errors #535

Closed

Description

@LunaStev

std::task::sleep_ms exposes Future<void>, but its shared timer-interest path represents invalid durations as an i32 error result. _interest rejects negative sleeps and deadline overflow with -22. That payload cannot be observed through the void future, so block_on(sleep_ms(-1)) can complete as if the request succeeded.

This should be resolved within the existing error/API style; it is not a proposal for new exception syntax.

Source evidence at the head of #520:

Acceptance:

  • Choose an observable failure path for invalid input and deadline overflow, consistent with the existing task and time APIs.
  • Cover negative, zero, small positive and overflowing durations using a controllable clock where necessary.
  • Ensure the compiler-generated sleep result layout matches the public API and no error payload is silently discarded.
  • Keep ordinary non-async main supported.

Related: #444.

Audit status: identified by static source inspection; the scenarios above have not been executed during this audit. This follows up the implementation introduced in draft PR #520.

Activity

  1. added
    bug
    help wanted
    on Sep 8, 2026
  2. self-assigned this
    on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions