-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
Error Details
- Level: Error
- Cannot read properties of undefined (reading 'clone')
- Location: (@reduxjs/toolkit/dist/query/rtk-query.esm)

Source Map
../../node_modules/@reduxjs/toolkit/dist/query/rtk-query.esm.js in at line 269:46
../../node_modules/@reduxjs/toolkit/dist/query/rtk-query.esm.js in step at line 23:23
../../node_modules/@reduxjs/toolkit/dist/query/rtk-query.esm.js in Object.next at line 4:53
../../node_modules/@reduxjs/toolkit/dist/query/rtk-query.esm.js in fulfilled at line 70:32
Our Setup
We’re using:
const baseQueryWithSessionHandler = async (args, api, extraOptions) => {
...
const result = await baseQuery(adjustedArgs, api, extraOptions);
if (result.data) {
result.data = { ...result.data, statusCode: result.meta.response.status };
return result;
}
...
};
Wrapped in retry() and custom backoff:
const staggeredBaseQueryWithSessionHandler = retry(baseQueryWithSessionHandler, {
backoff: customBackoff,
maxRetries: 3,
retryCondition: (error, args, { baseQueryApi, attempt }) => {
return (
args.method === 'GET' &&
attempt < 3 &&
error?.data?.message !== unauthorizedErrorMessage &&
error?.status !== 401
);
},
});
After digging into the source of fetchBaseQuery and retry, we observed:
meta is created and initially populated with request:
requestClone = request.clone();
meta = { request: requestClone };
Later, only if fetch() succeeds, response.clone() is called and attached to meta.response.
responseClone = response.clone();
meta.response = responseClone;
If the initial fetch fails (e.g. due to network or DNS issues), then meta.response is never set.
If a subsequent retry succeeds, the returned result includes data, but meta.response may still be missing

Metadata
Metadata
Assignees
Labels
No labels