Skip to content

Commit 8be1a63

Browse files
chore(fetchium): rewrite this change's changesets for React developers
Lead with what changes for an app using useQuery or fetchQuery, keep migration notes to a line or two, and drop internal detail. No source change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 94a754e commit 8be1a63

2 files changed

Lines changed: 18 additions & 36 deletions

File tree

‎.changeset/skip-write-and-snapshot-fixes.md‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22
'fetchium': patch
33
---
44

5-
Fixes for snapshots, unchanged-data skipping and streamed-event writes.
5+
Fixed stale data in components when a second query loads entities that are already in memory, and streamed updates that were lost on restart.
66

7-
- Development builds freeze snapshots, so mutating a query result (a `sort()` in render, an assignment) throws a `TypeError` where it happens. Production snapshots are not frozen; treat them as read-only. Fetchium no longer mutates objects you pass it, such as a snapshot handed back in a mutation's `effects`.
8-
- In development, the stale-snapshot check reports through the client's `log.error` and an uncaught error (a red box on React Native) instead of throwing during a snapshot, which stopped every other consumer from updating.
9-
- Mounting a second query whose entities are already in memory no longer leaves the first query's consumers with stale data. The in-memory data is used when it fits the new query's shape; otherwise the cached query is dropped and fetched instead of rendering with an item missing.
10-
- Streamed events persist every entity they change, including existing entities inside a `create` payload and stored entities that are not in memory. An entity built from events is merged into its stored record (new optional `QueryStore.mergeEntity`), so the fields its events did not carry survive a restart.
11-
- An entity that appears more than once in one response is applied and written once.
12-
- A store write that throws is retried by the next apply. `AsyncQueryStore` reports finished writes back to the client, and both built-in stores resize their LRU queue when `cache.maxCount` changes.
13-
- `QueryClient.destroy()` unsubscribes from the store, so a store no longer keeps every client created against it alive.
14-
- A query whose cached value was rejected fetches even within `staleTime`. Snapshots work for entities created before a hot reload.
7+
- Development builds freeze query results, so mutating one (such as calling `sort()` on a list in render) throws a `TypeError`. Copy the data first, and treat production results as read-only too.
8+
- In development, the stale-data check logs an error instead of throwing and blocking other components' updates.
9+
- Custom stores can add the new optional `QueryStore.mergeEntity`, so an entity built from streamed updates doesn't overwrite stored fields those updates didn't include. Without it, writes work as before.

‎.changeset/upgrade-behavior-changes.md‎

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,18 @@
22
'fetchium': major
33
---
44

5-
Upgrade notes: behavior an app can observe without using any new API. Each change has its own entry.
5+
Breaking changes. Most apps need no code changes, but tests that depend on loading frames, render counts or timers may.
66

7-
Rendering
8-
9-
- With `SyncQueryStore`, a cached query renders its data on the first render, with no loading frame. Tests that wait for a loading state or count renders may need updating.
10-
- A refetch, poll or streamed update with identical data does not re-render. `isPending` and `isFetching` still change.
11-
- `t.record` and `t.result` fields apply updates; a record field used to keep its old value.
12-
- List snapshots keep each row's identity when the list is inserted into or re-sorted.
13-
- A nested `t.object` or `t.record` value, or a live collection's value, is a new object after an update changes it, and keeps its identity otherwise.
14-
- Development builds freeze query results, so mutating one throws a `TypeError`. Treat production results as read-only too.
15-
16-
Fetching
17-
18-
- The first fetch, and a refetch without `debounce`, start on a microtask instead of after `setTimeout(0)`.
19-
- On resume, a subscription is restored before the request is sent, so a socket that replays a cached value no longer overwrites the fresh response.
20-
- Changing a Signal param mid-fetch aborts that fetch and fetches the new params. A late response for the old params is dropped.
21-
- A query unmounted mid-fetch refetches as soon as it mounts again, without showing the `AbortError`.
22-
- `retry: {}` and `retry: { retryDelay }` retry like `retry: true`. A `shouldRetry` hook can stop retrying permanent errors.
23-
- `shouldRetry`, `reactivationGraceMs`, `reactivationStaggerMs`, `activity` and `pollResumeJitterMs` are reserved `QueryClientConfig` names. Other keys still reach queries as `this.context`.
24-
- `QueryClient.destroy()` aborts every fetch in flight (whoever awaits one gets an `AbortError`), and nothing is written to the store after it.
25-
26-
Cache and store
27-
28-
- A cached entry that can't be applied is treated as a miss and fetched, even within `staleTime`.
29-
- A query whose result is not an entity caches each params key separately. Caches from earlier versions are corrected as each key is fetched again.
30-
- Streamed events persist the entities they change.
31-
- `QueryStore` gains optional `mergeEntity`, `onDelete`, `onPersisted`, `isSettled`, `hasQueuedDeletes` and `hasEntity`. A custom store without them writes as before. A store write that throws is retried.
32-
- `AsyncQueryStore` honors `cache.maxCount`, and both built-in stores resize their LRU queue when it changes.
7+
- **Results are frozen in development.** Mutating query data throws a `TypeError`; copy it first (`[...data.items].sort()`).
8+
- **Cached data shows on the first render** with `SyncQueryStore`. Update tests that wait for a loading state or count renders.
9+
- **Fetches start sooner.** The first fetch and refetches without `debounce` start on a microtask, not after `setTimeout(0)`; update tests that advance timers to see them.
10+
- **Identical data doesn't re-render.** A refetch, poll or streamed update with the same data skips the render; read `isFetching` instead of counting renders.
11+
- **Nested values change identity only when they change.** `t.object`, `t.record` and live-collection values are new objects after a change, so memoized children re-render; drop workarounds that forced it.
12+
- **`t.record` and `t.result` fields apply updates** instead of keeping their old value.
13+
- **Changing a Signal param mid-fetch aborts that fetch** and fetches the new params; the old response is dropped.
14+
- **`QueryClient.destroy()` aborts fetches in flight.** Code that awaits a query during teardown gets an `AbortError`; catch it.
15+
- **Awaiting a query can wait for a remount.** If the last component using a query unmounts before its first data arrives, `await fetchQuery(...)` waits for the next mount, `gcTime` collection or `destroy()` instead of rejecting with an `AbortError`.
16+
- **New reserved `QueryClientConfig` names:** `shouldRetry`, `reactivationGraceMs`, `reactivationStaggerMs`, `activity` and `pollResumeJitterMs` are read as options; rename custom context values that use them.
17+
- **`retry: {}` and `retry: { retryDelay }` now retry** like `retry: true`; use `retry: false` for no retries.
18+
- **`AsyncQueryStore` honors `cache.maxCount`.** Check the value if you set one.
19+
- **Custom `QueryStore`s** get new optional methods (`mergeEntity`, `onDelete`, `onPersisted`, `isSettled`, `hasQueuedDeletes`, `hasEntity`); without them nothing changes.

0 commit comments

Comments
 (0)