otherwise, queries will not stay in error state, but immediately go into pending + fetching again; this is also shown by the fact that an additional test now failed, because it didn't reset the error boundary correctly
* fix(query-core): don't finalizeThenable of different queries
if we have multiple promises in-flight, once they resolve, we need to make sure to not finalize with data / error from a different key; otherwise, we might see intermediate data of non-matching keys
* chore: extract promise tests to their own file
* test: add a test case for not resolving with intermediate data
* fix: only stop finalizing if we were previously in pending state
this makes sure we can read stale data from entries when switching to them immediately
* chore: add another test for background updates
* fix: move thenable-recreation into createResult
`updateResult` will only be called after a fetch, but when we switch between caches without a fetch, we will only call `createResult`; this fix stops `data` from the queryResult and the `thenable` to go out-of-sync; it's backwards compatible because `updateResult` also invokes `createResult`
* oops
* test: I'm sick of this flaky test
* chore: eslint reports an unused type assertion here
* feat(react-query): export QueryErrorResetBoundaryFunction
Export the QueryErrorResetBoundaryFunction render prop function
signature so users don't have to write wierd types of there own
* fix: add extra functions
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* refactor: handle type error when skipToken is present in suspense query
* test(react-query): add skipToken test for query hooks
* fix: merge form main
* ci: apply automated fixes
* feat(react-query): display “skipToken is not allowed” message in suspense hooks
* feat(react-query): display “skipToken is not allowed” message in suspense hooks
* feat(react-query): display “skipToken is not allowed” message in suspense hooks
* fix(react-query): update error message in useSuspenseInfiniteQuery
* test(react-query): add test case
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* fix(core): correctly gc query when suspense is used when query unmounts while it's still fetching
the `isFetchingOptimistic` workaround was added to make sure some "thing" I don't remember anymore works in suspense; we added tests for that;
however, in the meantime, we added a minimum gcTime for suspense queries, which also solves that problem (tests still work); this makes the `isFetchingOptimistic` workaround unnecessary, and this workaround is actually what causes the unmount issue
* chore: try to stabilize a flaky test
it's very likely that this used to be a disabled observer; one other case would be canceling a query while you were initially fetching it, but this is a weird corner case that brings all sorts of troubles
additionally, we can check for the queryFn being a skipToken; even if we have data in the cache, when the queryFn is currently set to skipToken, this is means we never want to see this query fetch