use_linked_state retries indefinitely after an initial LinkError::Internal
Problem
When use_linked_state performs its first client-side fetch and the request fails with LinkError::Internal, the hook repeatedly suspends and retries the same request.
The initial request removes its key from in_flight, but LinkError::Internal is deliberately not stored in the cache. On the next render there is no prepared state, cached result, or in-flight request, so another Suspension and HTTP request are created.
This prevents the error from being returned through LinkedStateHandle::as_result().
Steps To Reproduce
- Use
use_linked_stateduring a client-side navigation without prepared SSR state. - Configure the link endpoint to be unreachable or return malformed JSON.
- Render the component inside a
Suspenseboundary. - Observe that the same request is sent repeatedly after each suspension resumes.
Expected behavior
The initial request should complete exactly once and expose the resulting LinkError::Internal through as_result().
An explicit refresh() should remain responsible for retrying the request. A transient Internal error during refresh should not overwrite an existing cached value.
Environment:
- Yew version:
master - Rust version:
1.85or newer - Target:
wasm32-unknown-unknown - Package:
yew-link
Questionnaire
- I'm interested in fixing this myself but don't know where to start
- I would like to fix and I have a solution
- I don't have time to fix this right now, but maybe later
Source: yewstack/yew