* fix(query-core): ensure query refetches on mount/retry when status is error (#9728)
* fix: mark queries as invalidated on background errors instead of checking error status
- Remove error status check in shouldFetchOn
- Set isInvalidated: true in reducer when background error occurs (only if data exists)
- Add tests for staleTime: 'static' and non-static queries with background errors
This approach centralizes stale logic in isStale/isStaleByTime and prevents
regression where staleTime: 'static' queries would incorrectly refetch on
window focus after a background error.
* refactor: simplify isInvalidated logic in error case
Set isInvalidated: true unconditionally since queries with no data
are always considered stale per isStaleByTime logic.
* Apply suggestion from @TkDodo
* Apply suggestions from code review
* fix: eslint
* fix: disable retry in background error tests to prevent timeout
The tests were timing out because when refetch() throws an error, the
default retry mechanism (3 retries with exponential backoff) was being
triggered. With fake timers, the retry delays weren't being advanced,
causing the tests to hang.
Adding retry: false to both tests disables retries and allows them to
complete immediately after the error, which is appropriate for these
tests that specifically check background error behavior.
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* fix(query-core): prevent reducer from being called twice in streamedQuery #9787
- Fix bug where reducer was called twice for each chunk (once in setQueryData, once in loop)
- Store reducer result in variable to avoid duplicate calls
- Add test case to verify reducer is only called once per chunk
* fix(streamed-query): prevent reducer from being called twice
Fixed an issue where the reducer was being invoked twice when refetchMode is set to 'replace'.
Added a regression test to verify the fix.
Fixes#9787
* docs: add changeset and lockfile update
* fix(changeset): change version bump to patch
* Update streamedQuery.test.tsx
fix: lint
* fix: support refetchMode append and prevent double reducer calls
- Fix refetchMode append to preserve existing data on refetch
- Fix reducer being called twice by calling it once and storing result
- Update pnpm-lock.yaml to match main branch
* chore: update pnpm-lock.yaml to include size-limit dependencies
* ci: apply automated fixes
* refactor: simplify streamedQuery logic with clearer isReplaceRefetch condition
- Extract isReplaceRefetch variable for better readability
- Use explicit if-else instead of negated conditions
- Make it clearer when reducer is called in each branch
---------
Co-authored-by: TkDodo <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* chore: move consume aware signal logic to utils
* fix: add consume aware signal to streamedQuery
* test: add a test for not a signal that is not consumed by streamFn
* chore: add changeset
* fix: made queryFn of streamedQuery not consume signal directly (so that only streamFn can consume it)
* fix: made onCancelled get called only once
* fix: memoized getSignal and made sure it is called only once
* fix: no-unnecessary-condition
* chore: size-limit
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* feat: size-limit
* fix: script
* fix: add test:size to nx
* fix: skip install and build
* really
* fix: size-limit options
* ok we need build step
* fix: test-size runs as part of its own action
docs: update bundlephobia links to @tanstack/react-query
The bundlephobia links were pointing to the old react-query package (v3)
instead of the current @tanstack/react-query package.
Co-authored-by: Claude <noreply@anthropic.com>
* test(svelte-query-persist-client/PersistQueryClientProvider): switch to fake timers, replace 'waitFor' with 'advanceTimersByTimeAsync', and use 'sleep().then()' pattern
* test(svelte-query-persist-client/PersistQueryClientProvider): replace 'setQueryDefaults' with 'onFetch' callback in FreshData
* refactor(svelte-query-persist-client/FreshData): convert complex 'then' callback to async/await pattern
* test(angular-query-persist-client/withPersistQueryClient): switch to fake timers, replace 'waitFor' with 'advanceTimersByTimeAsync', use 'sleep().then()' pattern, replace 'screen' with 'rendered', add 'toBeInTheDocument', and add '@testing-library/jest-dom/vitest'
* test(angular-query-persist-client/withPersistQueryClient): replace 'async/await' with 'sleep().then()' pattern in queryFn and restoreClient
* refactor(angular-query-persist-client/withPersistQueryClient.test): convert complex 'then' callbacks to async/await pattern
* test(solid-query-persist-client/PersistQueryClientProvider): switch to fake timers, replace 'waitFor' with 'advanceTimersByTimeAsync', and use 'sleep().then()' pattern
* refactor(solid-query-persist-client/PersistQueryClientProvider.test): convert complex 'then' callback to async/await pattern
* fix: update react and nextJs
and add a nextJs16 integration test
* ci: apply automated fixes
* oops
* Update patch versions for React and TanStack packages
Updated the patch versions for various React and TanStack packages.
* fix: streamline dependencies
* bundle size
* fix lock file
* fix: update react in example
* skip test for now
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* docs(vue): change query keys example to typescript
This example is written in Javascript, and the fact that `todoId` is a `Ref` is a bit hard to identify.
I propose to migrate this example to Typescript, with an import to Vue's Ref type and make the parameter to the example composable explicit.
There are more docs that could be improved this way, if it suits you I could also make the changes to these docs :)
* ci: apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>