|
2 | 2 | 'fetchium': patch |
3 | 3 | --- |
4 | 4 |
|
5 | | -Timing fixes for mounting, unmounting and changing params. |
| 5 | +Fixed spurious errors and wrong data when a query mounts, unmounts or changes params quickly. |
6 | 6 |
|
7 | | -- A query mounted and unmounted in the same task (a redirect in a layout effect, a `replace` on mount) no longer shows an `AbortError` on its next mount: its first request finishes in the background. Releasing a `prefetch()` or `retain()` lease still aborts the fetch it started. |
8 | | -- A query unmounted mid-fetch and mounted again (a chart switched to another timeframe and back) no longer flashes an error. With no data yet it stays pending and refetches; with cached data it shows that data while it refetches. |
9 | | -- Changing a Signal param while a fetch is in flight aborts it and fetches the new params, instead of showing and caching the old params' response under the new key. A param set in the same task the query mounts is fetched right away, and a param change makes a remounted query refetch even if its old data was fresh. |
10 | | -- A query whose result is not an entity caches each params key separately. Previously every key's cache pointed at the latest params' data, so a cold start could show another key's data. This bug was in every earlier version. |
11 | | -- A stale query that mounts as the network goes offline waits for the network instead of rejecting with "Query is paused due to network status". |
12 | | -- A topic query mounted and unmounted in the same task no longer stays pending forever on its next mount. `TopicQueryAdapter.send()` honors its abort signal, including under React Native's `AbortController` polyfill. |
13 | | -- `QueryClient.destroy()` aborts and cancels every fetch; whoever awaits one gets an `AbortError`, and nothing is written to the store afterwards. |
14 | | -- With `gcTime: 0`, a query is collected only once its first fetch settles, so its entities no longer leak. |
15 | | -- Also: `reactivationStaggerMs` spreads the refetches that resume after a pause, a `__fetchNext()` page for stale params is dropped, and with an asynchronous store a param change during the cache load no longer applies the old params' entry. |
| 7 | +- Unmounting and remounting a query, in the same task or mid-fetch (switching a chart timeframe and back), no longer shows an `AbortError`. The query shows its cached data, or stays pending, while it refetches. One exception: a topic query with no data that mounts and unmounts in the same task shows the `AbortError` on its next mount until its data arrives (before, it stayed pending forever). |
| 8 | +- Changing a Signal param mid-fetch fetches the new params instead of showing the old params' response. A query whose result is not an entity now caches each params value separately; a cold start could show another params value's data. |
| 9 | +- `QueryClient.destroy()` aborts every fetch in flight, and code awaiting one gets an `AbortError`. |
0 commit comments