yewstack / yewstack/yew

use_linked_state retries indefinitely after an initial LinkError::Internal

Open
#4,218 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

  1. Use use_linked_state during a client-side navigation without prepared SSR state.
  2. Configure the link endpoint to be unreachable or return malformed JSON.
  3. Render the component inside a Suspense boundary.
  4. 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.85 or 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

Open the contributing guide

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.