Giter Site home page Giter Site logo

Comments (5)

iamandrewluca avatar iamandrewluca commented on June 9, 2024

Actually it will throw this warning in more cases for all this errors InvalidRSAA, RequestError, InternalError.

I think that this errors can be replaced with some raw objects. But this will imply a breaking change, because this errors a part of public API

https://github.com/agraboso/redux-api-middleware/blob/master/src/errors.js

from redux-api-middleware.

Goszu avatar Goszu commented on June 9, 2024

I am using redux toolkit with react native and custom fetch implementation and I've noticed something similar. It fails intermittently with the non-serializable error complaining about the provided fetch property. It is really hard to debug cause It happens like 2% of the times.

from redux-api-middleware.

iamandrewluca avatar iamandrewluca commented on June 9, 2024

A solution would be to implement toJSON for each non-serializable. But then we should also take care for reviving that non-serializable?!

from redux-api-middleware.

alolis avatar alolis commented on June 9, 2024

Same setup here although react-native is not the cause of the problem but the redux-toolkit serializability middleware which is enabled by default.

I am experiencing the same issue but with ApiError which is provided by redux-api-middleware and occurs on request failure type (401 HTTP status in my case).

@ghost, I know that this is bad and I prefer not to do it either, but you can disable the serialization check with the following:

import {apiMiddleware} from 'redux-api-middleware';
import {configureStore, getDefaultMiddleware } from '@reduxjs/toolkit';

const store = configureStore({
  reducer: rootReducer,
  middleware: [
    apiMiddleware,
    ...getDefaultMiddleware({
        serializableCheck: false
    }),
  ]
});

A better solution is probably to handle the failure type and return a plain object if you want to keep the serializable checker on:
https://www.npmjs.com/package/redux-api-middleware#failure-type-descriptors

It would be nice if by default the raw objects where returned from the errors or all of them to have a toJSON() implemented and by default to call that or via flag.

from redux-api-middleware.

Goszu avatar Goszu commented on June 9, 2024

I actually solved the problem. In my case it was my token refresh functionality and custom fetch attached to every action. After receiving 401 (expired token) I was getting new token and retrying all queued requests. All re-tries were getting non-serializable action warning. I simply passed my custom fetch implementation to createMiddleware() instead of passing to each action as a prop.

from redux-api-middleware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.