Repository navigation
Conversation
|
Visit the preview URL for this PR (updated for commit 80cd486): https://yew-rs-api--pr4219-master-68tx4rnl.web.app (expires Tue, 15 Sep 2026 13:14:45 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Size ComparisonDetails
✅ None of the examples has changed their size significantly. |
|
@WorldSEnder Modified. Please review it again. |
There was a problem hiding this comment.
Took a bit, since I am myself not familiar with this part of the library and was hoping Mado would chime in. So bear with and feel free to correct me too.
completed being an (unbounded) hashmap is I believe a memory leak (of all failed requests that never succeed). Keeping the old property of the LRU cache seems worthwhile.
I would phrase the property we want as follows: Every use of the use_linked_state hook has associated with it an input, call this the query. So when the input changes, the query does but it's the same hook. Every query should lead to at most one request to the backend (this is what I understand the bug is about). Multiple simultaneous queries from different uses of the hook for the same input should share the request (only one at best) - implemented by in_flight and refreshing. A query we already answered in SSR should lead to no request (subtly a different hook might have the same query without SSR, this can lead to a query request since cache is unreliable). And finally, memory should be proportional to the hooks used. After unmounting all, only a constant should be left, that's why LRU cache is used but HashMap is used only for things in flight.
The last property I think implies that two different hooks querying for the same input might not always share the result (which could have dropped out of the LRU already) and the hook needs to have a local cache, too.
EDIT: To come back to my earlier comment: each component should remember if a request failed and not retry again. The shared cache should be used only for successful requests.
Sorry this took so long, caching is hard.
|
Note: prior art for request coalescing in rs-singleflight could be helpful. |
Description
Fix the client-side
use_linked_stateretry loop caused by initialLinkError::Internalresults not being cached.Initial fetches now cache all completed results, including infrastructure errors. This allows the suspension to resolve and exposes the error through
LinkedStateHandle::as_result()instead of creating another identical request.Refresh behavior remains unchanged:
LinkError::Internalresults from background refreshes are not cached, so an existing stale value is preserved.Fixes #4218
Checklist