DioxusLabs / DioxusLabs/dioxus
Server Function Timeout
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
## Feature Request
```rs
#[server(timeout_secs=1.5)] // FeatureRequest 1: timeout attribute
async fn remote_call() -> Result {
// slow operation
}
match remote_call().await {
Err(ServerFnError::Timeout) => ...
...
}
// // FeatureRequest 2: with_timeout combinator
match remote_call().with_timeout(Duration::..).await {
...
}
```
Setting a timeout from a caller side with gloo_timers has disadvantages:
- The call site becomes very verbose
- the internal POST request for RPC cannot be explicitly cancelled on timeout
## Implement Suggestion
```rs
use gloo_timers::future::TimeoutFuture;
match select(rpc_call, TimeoutFuture::new(ms)).await {
Either::Left((response, timer)) => {
drop(timer);
return Ok(response);
}
Either::Right((rpc_call, _)) => {
rpc_call.cancel();
return Err(ServerFnError::Timeout)
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the server-function RPC handling and ServerFnError definitions, then assess the proposed timeout attribute and with_timeout combinator against the cancellation approach shown. Done should be defined by deciding which feature scope to implement and how timed-out calls report ServerFnError::Timeout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100