dfinity / dfinity/cdk-rs

Allow setting the timeout on every Call type

Open
#643 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
230
Forks
103
Avg merge
2d 13h
Merged PRs (30d)
2

Description

The code panics when changing the timeout of a call created using Call::unbounded_wait.
However, this doesn't make much sense, as both bounded and unbounded calls are represented by the same struct, with the only difference being an optional timeout.

In my use case, for instance, I have a service that receives a default Call instance and, only in specific cases, needs to set a timeout. Currently, this simple scenario is impossible to implement because there's no way to know if setting the timeout will cause a panic.

I’d propose removing the change_timeout() function and instead adding a simpler and more ergonomic alternative, such as:

    pub fn with_timeout(mut self, timeout_seconds: Option<u32>) -> Self {
        self.timeout_seconds = timeout_seconds;
        self
    }

Otherwise, please provide different structs for bounded and unbounded calls, so instead of a runtime panic, we can check at compile time whether a timeout can be set. But, at that point, please also add a way to convert from one type to the other.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Rust Call type and its unbounded_wait and change_timeout entry points. Review how bounded and unbounded calls store timeout state, then determine whether a unified timeout-setting API or separate convertible types fits the existing design. Done means changing a timeout no longer panics for an unbounded call and the chosen API is covered by relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.