Repository navigation
chore(deps): update dependency @reduxjs/toolkit to v2.14.0 - #856
renovate[bot] wants to merge 1 commit into
Conversation
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
3238ced to
a5d1543
Compare
|
View your CI Pipeline Execution ↗ for commit 3273c63
💡 Dealing with memory or CPU issues? See memory and CPU details with the resource usage add-on ↗. ☁️ Nx Cloud last updated this comment at |
a5d1543 to
528639a
Compare
528639a to
a82f0df
Compare
a82f0df to
ca68648
Compare
ca68648 to
3273c63
Compare
There was a problem hiding this comment.
Nx Cloud is proposing a fix for your failed CI:
We fixed the TS4023 build and typecheck failure that appeared with the @reduxjs/toolkit 2.14.0 bump. The reducers in node.slice.ts now take an explicit NodeStates state and cast to plain node types instead of Draft<...>. This keeps RTK's unexported WritableNonArrayDraft out of the inferred nodeSlice declaration, so tsc can emit it.
Tip
✅ We verified this fix by re-running @forgerock/davinci-client:build, @forgerock/davinci-client:typecheck.
Suggested Fix changes
diff --git a/packages/davinci-client/src/lib/node.slice.ts b/packages/davinci-client/src/lib/node.slice.ts
index f9d68af..d866b71 100644
--- a/packages/davinci-client/src/lib/node.slice.ts
+++ b/packages/davinci-client/src/lib/node.slice.ts
@@ -18,7 +18,7 @@ import { getCollectorErrors } from './node.utils.js';
/**
* Import the types
*/
-import type { Draft, PayloadAction } from '@reduxjs/toolkit';
+import type { PayloadAction } from '@reduxjs/toolkit';
import type { MetadataCollector, SubmitCollector } from './collector.types.js';
import type {
@@ -71,10 +71,10 @@ export const nodeSlice = createSlice({
* @returns {ErrorNode} - The error node
*/
error(
- state,
+ state: NodeStates,
action: PayloadAction<{ data: DavinciErrorResponse; requestId: string; httpStatus: number }>,
) {
- const newState = state as Draft<ErrorNode>;
+ const newState = state as ErrorNode;
// Reference to the original response from DaVinci in the cache
newState.cache = {
@@ -117,14 +117,14 @@ export const nodeSlice = createSlice({
* @returns {FailureNode} - The failure node
*/
failure(
- state,
+ state: NodeStates,
action: PayloadAction<{
data: DaVinciFailureResponse | unknown;
requestId: string;
httpStatus: number;
}>,
) {
- const newState = state as Draft<FailureNode>;
+ const newState = state as FailureNode;
newState.cache = {
key: action.payload.requestId,
@@ -172,14 +172,14 @@ export const nodeSlice = createSlice({
* @returns {ContinueNode} - The next node
*/
next(
- state,
+ state: NodeStates,
action: PayloadAction<{
data: DaVinciNextResponse;
requestId: string;
httpStatus: number;
}>,
) {
- const newState = state as Draft<ContinueNode>;
+ const newState = state as ContinueNode;
const collectors = nodeCollectorReducer([], {
type: action.type,
@@ -234,14 +234,14 @@ export const nodeSlice = createSlice({
* @returns {SuccessNode} - The success node
*/
success(
- state,
+ state: NodeStates,
action: PayloadAction<{
data: DaVinciSuccessResponse;
requestId: string;
httpStatus: number;
}>,
) {
- const newState = state as Draft<SuccessNode>;
+ const newState = state as SuccessNode;
newState.cache = {
key: action.payload.requestId,
@@ -277,8 +277,8 @@ export const nodeSlice = createSlice({
* @param {PayloadAction<unknown>} action - The action to be dispatched
* @returns {ContinueNode} - The next node
*/
- update(state, action: ReturnType<typeof updateCollectorValues>) {
- const newState = state as Draft<ContinueNode>;
+ update(state: NodeStates, action: ReturnType<typeof updateCollectorValues>) {
+ const newState = state as ContinueNode;
newState.client.collectors = nodeCollectorReducer(newState.client.collectors, action);
@@ -292,12 +292,12 @@ export const nodeSlice = createSlice({
* @returns {ContinueNode} - The next node
*/
poll(
- state,
+ state: NodeStates,
action: PayloadAction<{
requestId: string;
}>,
) {
- const newState = state as Draft<ContinueNode>;
+ const newState = state as ContinueNode;
// Update retries remaining in poll collector
newState.client.collectors = nodeCollectorReducer(newState.client.collectors, action);
Or Apply changes locally with:
npx nx-cloud apply-locally sfy1-EWkZ
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
Note
This PR body was truncated due to platform limits.
This PR contains the following updates:
2.10.1→2.14.0Release Notes
reduxjs/redux-toolkit (@reduxjs/toolkit)
v2.14.0Compare Source
This feature release speeds up the dispatch path and RTK Query's
Apitype checking, shrinkscreateSlicein esbuild bundles, adds RTK-ownedDraftandPatchtypes so emitted declarations no longer reference Immer, addsremoveMany({ where })andselectByIdsto the entity adapter, adds RTK Query cache entry selectors and a DevTools action sanitizer, and fixes a very long list of RTK Query lifecycle, polling, upsert, timer, hook andfetchBaseQuerybugs.Note that we just announced our roadmap to Redux Toolkit 3.0, which includes both a large set of planned 2.x features and improvements, and planned 3.0 breaking changes. The fixes and updates in this release help pave the way for all of those efforts. We'd also appreciate feedback on the linked RTK Query usage patterns and 3.0 planned breaking changes discussion threads.
Changelog
Dispatch Performance
Every dispatched action runs through every reducer and middleware, so small costs on that path add up. We added a benchmark harness for the dispatch path and used it to find several places where RTK did work for actions it didn't care about.
createAction(...).matchnow comparesaction.typebefore callingisAction, so a non-matching action costs a property read.createReducerno longer allocates arrays on every dispatch to collect case and matcher reducers. SincecreateSlicebuilds its reducer withcreateReducer, every slice reducer gets this improvement.The listener middleware used to copy its listener list and call every predicate for every action. It now keeps a snapshot that is rebuilt only when listeners are added or removed, and that snapshot knows which action types have
typeoractionCreatorlisteners. If an action's type isn't in that set and there are nomatcherorpredicatelisteners, the middleware skips the loop entirely.The RTK Query root reducer now returns the existing state for actions that none of its slices handle, instead of running all five slice reducers. It also skips rewriting a query's provided tags when the new tags are the same as the stored ones, so re-fetching a query that returns the same tags no longer creates new
providedstate.Some numbers from the PR benchmarks (Node 26, ops/sec unless noted):
actionCreatorlisteners, matching actioncreateSlice, 20 slices, unrelated actionThe listener middleware numbers are the biggest change, because the old cost grew with the number of listeners. Apps with a handful of listeners will see much smaller gains.
The RTK Query middleware also does less work keeping the store's
subscriptionsstate in sync (#5499). It used to JSON-copy the whole subscriptions object and diff it with Immer every 500ms while subscriptions were changing. It now records which cache keys changed and writes one patch per key. Keys that didn't change keep their object references, so the Redux DevTools no longer receive a full copy ofsubscriptionson every sync. Polls,refetch()calls and tag invalidation refetches don't add subscribers, so they no longer schedule a sync at all. The visible difference: a cache key that only ever hadsubscribe: falserequests no longer shows up as an empty{}insubscriptions.Smaller
createSliceBundles With esbuildcreateSlicereferencesasyncThunkCreatorso thatcreate.asyncThunkworks in thereducerscallback. esbuild couldn't tell that theasyncThunkCreatorobject was free of side effects, so it always bundledcreateAsyncThunkalong withcreateSlice. webpack already dropped it. We've marked it as pure, and an esbuild bundle that imports onlycreateSliceis now about 1 kB smaller (brotli).Faster RTK Query
ApiType CheckingThe
Apitype combines every registered module (core, React hooks, and any third-party modules) by runningUnionToIntersectionover the module names. TanStack Table hit the same cost with the same design, and found that writing out the known intersection and adding variance annotations helped a lot.We've done the same thing here:
Apiuses the core module type directly, andApiModuleshasin outvariance annotations. On a test app with one ~50-endpointcreateApi, type instantiations dropped 22% and check time dropped about 25% on TS 6, and about 18% on the TS 7 native preview. Third-party modules likengrx-rtk-querysaw 7-8% fewer instantiations. There are no runtime changes.RTK-Owned
DraftandPatchTypesRTK used to re-export Immer's
Drafttype, and used Immer's types in signatures likeCaseReducerandPatchCollection. That meant the.d.tsfiles TypeScript generated for your slices referencedimmer. With a package manager layout whereimmerisn't hoisted, those declarations failed to build with TS2883 (#5516). Re-exporting doesn't fix that, so RTK now declares its ownDraft,WritableDraftandPatchtypes with the same shapes as Immer's. Emitted declarations now point at@reduxjs/toolkitinstead. Our type tests check that RTK'sDraftand Immer'sDraftstay interchangeable, so code that mixescastDraftorcurrentwith RTK's types keeps working. We also bumped theimmerdependency to^11.2.9.There are a few other type additions in this release:
ApiRootStatereplaces RTK Query'sRootStatetype, which is now deprecated.RootStatewill be removed in 3.0.TypedAddListenerActionandTypedRemoveListenerActiondescribe the actions thataddListenerandremoveListeneractually dispatch. The default payload type ofTypedAddListenerandTypedRemoveListeneris now the listener options object, soaddListener.match(action)no longer claimsaction.payloadhas fields likeidandunsubscribethat don't exist at runtime.dispatch(removeListener(...))is typed as returningbooleananddispatch(clearAllListeners())as returningvoid, matching the runtime.UseQueryStateDefaultResultandUseInfiniteQueryStateDefaultResultare exported from@reduxjs/toolkit/query/react, for wrapping hooks with a genericselectFromResult.RTK Query Cache Entry Selectors
We've had requests for a way to list everything in the cache for an endpoint (#2995).
api.util.selectEntriesForEndpoint(state, endpointName)returns all cache entries for one query or infinite query endpoint, andapi.util.selectAllQueryEntries(state)returns them for every endpoint. Each item has the entry's fields plus itsqueryCacheKey, and is typed for its endpoint. Both selectors are memoized. There's also a new exportedQueryCacheEntry<Definition>type.DevTools Action Sanitizer
All RTK Query requests use the same few action types, so the Redux DevTools show a long list of
api/executeQuery/fulfilledactions, and you have to open each one to see which endpoint it was for. The newcreateApiActionSanitizer(api)returns a function for the DevToolsactionSanitizeroption that renames those actions for display, likeapi/executeQuery/fulfilled (getPosts). The dispatched actions aren't modified.See the
createApiActionSanitizerdocs for combining sanitizers for multiple APIs.Entity Adapter Additions
adapter.removeManynow accepts a{ where }object, and removes every entity whose fields match all the given values (#5524):The match object is typed as
Partial<T>, and values are compared with===. Awhereobject with no keys removes nothing, so a filter built at runtime that ends up empty can't clear the collection by accident. UseremoveAllfor that. There's also a new exportedRemoveManyFilter<T>type.getSelectors()now includesselectByIds(state, ids), which returns the entities for the given ids in the order ofids, skipping ids that don't exist.removeManyis also faster. It used to filter the Immer draft of theidsarray, which reads every element through the draft proxy. It now filters a plain copy against aSetof removed ids.RTK Query Fixes
Lifecycles:
cacheDataLoadednow only resolves for a response from a request that started while that lifecycle was waiting. A late response from before aremoveQueryResultno longer resolves the next lifecycle on the same key with discarded data. Re-triggering a mutation with the samefixedCacheKeynow ends the previousonCacheEntryAddedlifecycle, so itscacheEntryRemovedcleanup runs instead of leaking. If that earlier trigger is still in flight, itscacheDataLoadednow rejects instead of never settling. Thanks to @hamarshehmhmd for the analysis in #5539.getCacheEntry()in a mutation'sonQueryStartednow finds the entry forfixedCacheKeymutations instead of always returninguninitialized.Synchronous throws from
onQueryStartedandonCacheEntryAddedare now caught and logged withconsole.error. Before, a sync throw inonQueryStartedescaped thependingdispatch and failed the request without ever callingqueryFn. We also added a dev warning whenupdateCachedDatais called before the entry has any data, since that call does nothing.Polling: Polling now stops after the last unsubscribe even if the subscription cleanup hasn't run yet (thanks to @LeulTew for the original fix in #5444). A due poll re-reads
skipPollingIfUnfocusedinstead of using the value from when the timer was set, and skips the poll if a request for that entry is already pending.pollingIntervalvalues above 2^31-1 ms are now clamped with a dev warning, since larger values overflowsetTimeoutand fire after 1ms. Removing a cache entry withremoveQueryResultnow stops its poll timer right away, and switching a subscriber to a slowerpollingIntervalnow reschedules the pending poll instead of letting the old, faster one fire once more. We also fixed a stale internal poll record that could blockupdatePollingInterval, andfetchBaseQuerynow clears itstimeouttimer when the request finishes.Upserts: A failed
upsertQueryDataover an existing entry (for example, from aresponseSchemavalidation error) no longer leaves that entry stuck inpending.upsertQueryEntriesnow skips bad entries one at a time instead of failing the whole batch: unknown or mutation endpoint names and throwingprovidesTagscallbacks are skipped, with dev warnings.Timers and multiple stores:
resetApiStatenow clears the subscription sync timer and the state for delayed tag invalidation, so work scheduled before the reset can't fire afterward. AkeepUnusedDataForremoval timer is now cleared when the key gets a new subscriber or is removed withremoveQueryResult, so an old timer can't remove a newer entry for the same key. Repeatedinitiate(arg, { subscribe: false })calls that hit the cache no longer push back thekeepUnusedDataForremoval, which could keep unused data around indefinitely (#4480, thanks @veksa!).setupListenersnow works with more than one store. Before, only the first store got focus and online events.Hooks: A query that failed before it ever got data now reports
isLoading: truewhen it refetches, instead of havingisLoading,isErroranddataall falsy while the request is pending (#4449, thanks @AnimeshPandey!). This undoes a change from 2.2.4 (#4364) that keptisLoadingfalse when a second hook subscribed to an errored entry. If a parent rendersnullwhileisLoadingis true and a child mounts the same query, the parent now unmounts the child on each refetch, and the two can loop. Render the child based ondataorisErrorinstead. Query args containingNaNno longer cause an endless refetch loop when the query errors. This was a regression from 2.9.0, where arg comparison treatedNaNas never equal to itself (#5338, thanks @aagostino31!).fetchNextPage()andfetchPreviousPage()no longer send a request when the infinite query hook's arg isskipToken, andinitiate(skipToken)no longer sends a request for any query or infinite query endpoint (#5028, thanks @haigou-web!).fetchBaseQuery: Anullbody no longer throwsCannot read properties of nullbefore the request is sent (thanks @dfedoryshchev!). An explicitcontent-typeheader is now kept forArrayBuffer, typed array andBlobbodies, which broke presigned S3 and GCS uploads. It's still removed forFormDataand for a JSON content type on a non-JSON body, and that JSON content type check is now case-insensitive (thanks @tad-bit-better!). A customresponseHandlerthat throws or rejects with a falsy value likeundefinednow produces aPARSING_ERROR, instead of being treated as a successful response (#5480, thanks @JunaidAhamed-7777!). Atimeoutthat fires while the response body is being read is now reported asTIMEOUT_ERRORinstead ofPARSING_ERROR(thanks @Gurmehar-git!).Other RTKQ fixes: An overlapping refetch now stays registered as the running query, so later calls join it and aborting it works (thanks @tedy69!). Apps with many
createApimiddlewares could hit a "Maximum call stack size exceeded" error when the middlewares registered themselves on the first query. Registration no longer restarts dispatch from the start of the middleware chain (thanks @PabloJoan!).api.enhanceEndpoints({ endpoints })now logs an error in development when it names an endpoint that doesn't exist, which usually means a typo.RTK Query thunk actions now include
startedTimeStampand a per-storeseqcounter in thefulfilledand rejected-with-value meta, matching the request'spendingaction, so you can tell which request a response belongs to and in what order requests started. Rejections for aborted requests and unhandled errors don't include these fields yet.Other Fixes
The listener middleware's
take(),condition()anddelay()no longer leave their timers running after the listener is cancelled or the action arrives first.The
autoBatchEnhancerraffallback no longer throws acancelAnimationFrameReferenceError in test environments that delete window globals during teardown (thanks @msutkowski!).RTK Query hooks now log a dev warning when they render with a different store than the one they first subscribed to. If you swap the store passed to
<Provider>, give the Provider akeythat changes with the store so the tree remounts.The serializability check middleware now reports a circular reference in state or actions as a non-serializable value, instead of overflowing the stack (thanks @OskarEichler!).
@types/reactis now declared as an optional peer dependency. RTK's React entry points import React types, and with pnpm's isolated linker or a global virtual store, TypeScript couldn't find them and those types becameany(thanks @unrevised6419!).What's Changed
cancelAnimationFrameReferenceError in the autoBatch raf fallback by @msutkowski in #5462take/delaytimer leak and documentisAnyOfmatcher inference by @markerikson in #5538removeManyin the entity adapter by @markerikson in #5546pendingafter failedupsertQueryData, and skip badupsertQueryEntriesentries by @markerikson in #5542cacheDataLoaded,fixedCacheKey,getCacheEntry, and sync throws in RTKQ lifecycles by @markerikson in #5543setupListenerswith multiple stores by @markerikson in #5545Apitype checking by writing out the core module by @markerikson in #5547nullbody as jsonifiable infetchBaseQueryby @dfedoryshchev in #5450keepUnusedDataForon condition-skipped queries by @veksa in #5343fetchBaseQueryby @tad-bit-better in #5479TIMEOUT_ERRORby @Gurmehar-git in #5482NaNby @aagostino31 in #5339isLoadingstayingfalsewhen refetching after an error with no data by @AnimeshPandey in #5470skipTokenin infinite query triggers by @haigou-web in #5464Full Changelog: reduxjs/redux-toolkit@v2.13.0...v2.14.0
v2.13.0Compare Source
This feature release updates our build tooling to TSDown and PNPM, adds official TypeScript 7 support, and includes a long list of bugfixes across RTK Query,
createAsyncThunk,createEntityAdapter, andcombineSlices.Changelog
Build Tooling Updates
We've fully modernizing modernized our build tooling across all of the Redux repos. That included switching from Yarn to PNPM, ESLint to Oxlint, Prettier to Oxfmt, and TSUp to TSDown.
The part that matters for users is that we now build the package with TSDown instead of
tsup. The package layout,exportsdefinitions, and exported APIs are all unchanged from 2.12. We've checked the new build withattw, and verified that CJS and ESM entry points load in both dev and prod builds, and that thelegacy-esmartifacts still target ES2017. The contents of the bundles do look a bit different (smaller CJS artifacts, slightly different helper output in thelegacy-esmfiles). If you see any behavior differences that look build-related, please file an issue!This is also our first release published via the updated PNPM-based workflow, still using NPM Trusted Publishing. We've also added
pkg.pr.newpreviews for every commit, so you can try out a PR build before it's released.Docs Updates
We've shipped a new combined Redux libraries docs site! The core docs site at https://redux.js.org now contains the docs for all of our libraries: Redux core and usage guides, Redux Toolkit, React Redux, and Reselect. The prior standalone docs sites for RTK, R-R, and Reselect now redirect to their respective sections of the combined docs. We've also done a major cleanup pass on the docs, deduplicating pages that had similarities (like the Next.js or RTK2 migration pages that lived in both the core and RTK docs), and updating outdated content (modernizing example code snippets, deleting dead links, and making RTK and hooks the default patterns shown). The RTK content now lives at https://redux.js.org/toolkit/ .
TypeScript 7 Support
TS 7.0 (the native Go port) is now out! We fixed the remaining type errors in RTK when checked by TS 7.0 and 7.1, and TS 7.0 is now part of our CI test matrix.
Per our TS support policy of matching DefinitelyTyped's support window, we've also updated our support matrix to TS 5.6+. As always, RTK may still work with earlier versions, but we no longer test against them.
RTK Query Fixes
useQueryState(and thususeQuery) was passing a new inline selector touseSelectoron every render, and also reading the store directly during render. The selector is now memoized, and the direct store read is gone. This also fixes a bug whereisSuccesscould flip fromfalsetotrueon an unrelated re-render while a query was refetching after an error.isSuccessnow correctly staysfalsein that case.datanow reflects cache updates made viaupdateQueryDatawhile a refetch is in flight, instead of showing the previous result.Polling now reads the current cache state when each poll fires, rather than the state at the time the poll was scheduled. This means
skipPollingIfUnfocusedrespects focus loss that happens after scheduling, and polls stop if their cache entry was removed.We fixed a race where a duplicate query request rejected by the thunk condition could cause queued tag invalidations to run too early and be lost, leaving stale data in the cache.
Tags with falsy ids like
0now invalidate and clean up correctly.Lazy query hooks now re-subscribe correctly when effects restart while the hook state is preserved, such as with Fast Refresh or
<Activity>.Infinite queries no longer trigger
onQueryStartedwhen fetching past the end of the list, and the infinite query hook result type now includes the page error flags.fetchBaseQueryonly treats a URL as absolute if it starts with a scheme.We also fixed an error when rehydrating state for an endpoint name that has no definition.
Other Fixes
createAsyncThunkno longer swallows aborts that happen before thependingaction is dispatched, and now correctly setsrejectedWithValuewhenrejectWithValueis called with a falsy payload.createEntityAdapter'ssetAllnow keeps the last item when given duplicate IDs, matchingsetMany. The sorted adapter'supdateManynow merges multiple updates for the same ID before applying them.combineSlicesnow keeps its internal state proxy cache per instance, so multiple combined reducers no longer interfere with each other.The immutability check middleware now handles circular references in state.
The dynamic middleware now caches its composed middleware chains when the list of middleware hasn't changed.
What's Changed
pkg.pr.newby @aryaemami59 in #5256entityAdapter):setAllwith duplicate IDs keeps last occurrence (consistent withsetMany) by @JSap0914 in #5321createAsyncThunkaborts that happen before pending by @chatman-media in #5314useRef<T | undefined>(undefined)usages in RTK Query hooks by @DucMinhNe in #5315onQueryStartedfrom triggering at end-of-list by @joseph0926 in #5182remark-typescript-toolsand update to TS7 by @markerikson in #5390rejectedWithValuefor falsyrejectWithValuepayloads by @dfedoryshchev in #5395immutableStateInvariantMiddlewareby @hamed-bavar in #5433useQueryStateandisSuccessduring refetch-after-error by @markerikson in #5456Full Changelog: reduxjs/redux-toolkit@v2.12.0...v2.13.0
v2.12.0Compare Source
This feature release adds RTK usage skills files (via TanStack Intent) exports the RTK Query hook options types for reusability, fixes issues with infinite query status flags and batching handling, and makes some small TS improvements.
Changelog
Skills Files
We've generated agent skill files that are now included in the RTK package itself in a
skillsfolder. They cover using and migrating to modern RTK, client and server state management, and handling side effects. You can point your agent at these skills yourself, or use TanStack Intent to pick them up.TypeScript Improvements
The types for our RTK Query hook options are now exported, which lets you stop using
Parametersto extract those types for use in your own code.The types for listener middleware matchers were tweaked to allow
interface-based type guards, not justtype-based definitions.The internal
IgnorePathstype was renamed toIgnoredPathsfor consistency.We now use the built-in
NoInferutil that comes with TS 5.4+.Fixes
We fixed handling of the
isSuccessstatus flag when switching infinite query cache entries. This should prevent accidental UI flashes that were occurring due to this flag accidentally flipping.We've added a 100ms timeout fallback to the
autoBatchenhancer'srequestAnimationFrametimer. We had several reports thatrAFdidn't work correctly when used in background tabs / opened windows, and that RTK never updated the UI. This should ensure that the updates flush correctly.What's Changed
IgnorePathstype toIgnoredPathsby @Ri5ha6h in #5284NoInferutility type by @aryaemami59 in #5289Full Changelog: reduxjs/redux-toolkit@v2.11.2...v2.12.0
v2.11.2Compare Source
This bugfix release updates the
AbortSignalhandling to fall back ifDOMExceptionisn't available (such as RN environments), and updates theTypedUseInfiniteQueryHookResulttype to correctly includefetchNextPage/fetchPreviousPagefields.Changelog
Bugfixes
The
AbortSignalchanges in 2.11.1 usedDOMExceptionin a couple places to match the expected behavior ofAbortSignal, but turns out that's not available in environments like React Native. We've updated the logic to fall back to a plainErrorifDOMExceptionisn't available.The
TypedUseInfiniteQueryHookResulttype wasn't correctly including thefetchNextPage/fetchPreviousPagefields, and now it does.What's Changed
TypedUseInfiniteQueryHookResultby @markerikson in #5165Full Changelog: reduxjs/redux-toolkit@v2.11.1...v2.11.2
v2.11.1Compare Source
This bugfix release fixes an issue with our internal
AbortSignalhandling that was reported as causing an error in a rare reset situation. We've also restructured our publishing process to use NPM Trusted Publishing, and updated our TS support matrix to only support TS 5.4+.Changelog
Publishing Changes
We've previously done most of our releases semi-manually locally, with various release process CLI tools. With the changes to NPM publishing security and the recent wave of NPM attacks, we've updated our publishing process to solely use NPM Trusted Publishing via workflows. We've also done a hardening pass on our own CI setup.
We had done a couple releases via CI workflows previously, and later semi-manual releases caused PNPM to warn that RTK was no longer trusted. This release should be trusted and will resolve that issue.
Thanks to the e18e folks and their excellent guide at https://e18e.dev/docs/publishing for making this process easier!
TS Support Matrix Updates
We've previously mentioned rolling changes to our TS support matrix in release notes, but didn't officially document our support policy. We've added a description of the support policy (last 2 years of TS releases, matching DefinitelyTyped) and the current oldest TS version we support in the docs:
As of today, we've updated the support matrix to be TS 5.4+ . As always, it's possible RTK will work if you're using an earlier version of TS, but we don't test against earlier versions and don't support any issues with those versions.
We have run an initial test with the upcoming TS 7.0 native
tsgorelease. We found a couple minor issues with our own TS build and test setup, but no obvious issues with using RTK with TS 7.0.Bug Fixes
A user reported a rare edge case where the combination of
resetApiStateandretry()could lead to an error calling anAbortController. We've restructured ourAbortControllerhandling logic to avoid that (and simplified a bit of our internals in the process).What's Changed
Full Changelog: reduxjs/redux-toolkit@v2.11.0...v2.11.1
v2.11.0Compare Source
This feature release upgrades our Immer dependency to v11 to pick up the additional recent performance optimizations, adds a new
refetchCachedPagesoption to allow only fetching the first cached page, and fixes an issue with regex ignore paths in the immutability middleware.Changelog
Immer v11 Performance Improvements
As described in the release notes for v2.10.0, we recently put significant effort into profiling Immer, and contributed several PRs that aimed to optimize its update performance.
v2.10.0 updated to use Immer 10.2.0, which added the first smaller set of perf updates. That included a new Immer option to disable "strict iteration" to speed up iterating copied objects, and we specifically applied that change in RTK under the assumption that standard plain JS objects as Redux state shouldn't have unusual keys anyway. Overall, this appears to boost Immer update perf by ~+20% over v10.1 depending on update scenario.
Immer v11.0.0 was just released and contains the second perf PR, a major internal architectural rewrite to change the update finalization implementation from a recursive tree traversal to a set of targeted updates based on accessed and updated fields. Based on the benchmarks in the PR, this adds another ~+5% perf boost over the improvements in v10.2, again with variations depending on update scenario. In practice, the actual improvement may be better than that - the benchmarks list includes some array update cases which actually got a bit slower (and thus drag down the overall average), and a majority of update scenarios show anywhere from +25% to +60% faster than Immer v10.1!
As a practical example, we have an RTK Query stress test benchmark where we mount 1000 components with query hooks at once, unmount, then remount them. We ran the same benchmark steps for RTK 2.9 and Immer 10.1, and then RTK 2.10+ and Immer 11. The overall scripting time dropped by about 30% (3330ms -> 2350ms), and the amount of time spent in Immer methods and the RTK reducers dropped significantly:
<img width="2561" height="1548" alt="image" src="h
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.