* add timeoutManager class
* add additional types & export functions
* convert all setTimeout/setInterval to managed versions
* tweaks
* add claude-generated tests
* tests
* revert changes in query-async-storage-persister: no path to import query-core
* re-export more types
* console.warn -> non-production console.error
* query-async-storage-persister: use query-core managedSetTimeout
* pdate pnpm-lock for new dependency edge
* sleep: always managedSetTimeout
* remove managed* functions, call method directly
* remove runtime coercion and accept unsafe any within TimeoutManager class
* cleanup; fix test after changes
* name is __TEST_ONLY__
* notifyManager: default scheduler === systemSetTimeoutZero
* Improve TimeoutCallback comment since ai was confused
* remove unnecessary timeoutManager-related exports
* prettier-ify index.ts (seems my editor messed with it already this pr?)
* continue to export defaultTimeoutProvider for tests
* oops missing import
* fix: export systemSetTimeoutZero from core
* ref: use notifyManager.schedule in createPersister
because it needs to work with whatever scheduleFn we have set there
* ref: move provider check behind env check
* docs
* doc tweaks
* doc tweaks
* docs: reference timeoutManager in discussion of 24 day setTimout limit
* Apply suggestion from @TkDodo
* Apply suggestion from @TkDodo
* chore: fix broken links
* docs: syntax fix
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* refactor: narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void
Previously, the `onSuccess`, `onError`, `onMutate`, and `onSettled` callbacks were typed as `() => Promise<unknown> | unknown`. While `unknown` is technically valid, it implies that the return value might be used, assigned, or further processed. However, throughout the codebase, these callbacks are invoked solely for their side effects, and their return values are always ignored. Narrowing the type to `Promise<void> | void` makes this intent explicit, clarifies that any return value will be discarded, and prevents misleading type signatures that suggest otherwise.
This commit narrows their types to `() => Promise<void> | void`, which more accurately reflects their intended use.
* docs: update callback return types to Promise<void> | void in mutation-related documentation
This commit refines the documentation for mutation-related callbacks (`onSuccess`, `onError`, `onSettled`, and `onMutate`), changing their return types from `Promise<unknown> | unknown` to `Promise<void> | void`.
* docs(react-query): fix incorrect paths in documentation
The documentation contained incorrect file paths.
Fixed the incorrect paths to match the actual directory structure.
* docs(react-query): fixed incorrect relative path (./ -> ../)
* wip - 1
* Fix more links
* Fix one more link
* Another one
* Update a link
* Fix the broken links in the Angular docs
* Fix the broken links in the Vue docs
* Fix the Svelte links in the docs
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* refactor: add scope to mutationCache internally
* refactor: remove unused defaultOptions on mutation
this private field is a leftover from v4
* feat: make sure to not run mutations if there is already one running in the scope of this mutation
* feat: make sure mutations in the same scope can run in serial
* fix: find a _lot_ better way to determine if a mutation can run
* test: widen test scenario to include scopes
* fix: there is a difference between starting and continuing
when starting, we need to check the networkMode differently than when continuing, because of how offlineFirst works (can start, but can't continue)
* refactor: switch to a scope object with `id`
* feat: dehydrate and hydrate mutation scope
* fix: initiate the mutationCache with a random number
since we use the mutationId to create the default scope, and the mutationId is merely incremented, we risk colliding scopes when hydrating mutations into an existing cache. That's because the mutationId itself is never dehydrated. When a mutation gets hydrated, it gets re-built, thus getting a new id. At this point, its id and the scope can differ. That per se isn't a problem. But if a mutation was dehydrated with scope:1, it would put into the same scope with another mutation from the new cache that might also have the scope:1.
To avoid that, we can initialize the mutationId with Date.now(). It will make sure (or at least very likely) that there is no collision
In the future, we should just be able to use `Crypto.randomUUID()` to generate a unique scope, but our promised compatibility doesn't allow for using this function
* test: hydration
* test: those tests actually fail because resumePausedMutations is still wrongly implemented
* fix: simplify and fix resumePausedMutations
we can fire off all mutations at the same time - only the first one in each scope will actually fire, the others have to stay paused until their time has come. mutation.continue handles this internally.
but, we get back all the retryer promises, so resumePausedMutations will wait until the whole chain is done
* test: more tests
* refactor: scopeFor doesn't use anything of the mutationCache class
* docs: scoped mutations
TanStack Router uses path-based navigation instead of route-based navigation, so many of the relative documentation links will be invalid after migration. This fixes that.