use_linked_state retries indefinitely after an initial LinkError::Internal
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 32.8k
- Forks
- 1.5k
- Avg merge
- 5h 34m
- Merged PRs (30d)
- 2
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the yew-link implementation of use_linked_state and trace its initial client-side fetch through LinkedStateHandle::as_result(); compare that path with refresh(). Run the client-side navigation reproduction with an unreachable or malformed link endpoint inside Suspense. Done means the initial request suspends only once, exposes LinkError::Internal through as_result(), and refresh() remains the explicit retry path without replacing an existing cached value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100