Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding a warning if default middlewares run too slow #412

Closed
matthieudumas opened this issue Mar 6, 2020 · 12 comments
Closed

Consider adding a warning if default middlewares run too slow #412

matthieudumas opened this issue Mar 6, 2020 · 12 comments

Comments

@matthieudumas
Copy link

I've switched to redux toolkit for a new project built with create react app, and encountered a big performance issue during development. Long story short, I was storing large amounts of json in the store and redux toolkit's default dev middlewares (redux-immutable-state-invariant and serializable-state-invariant-middleware) were taking around 400ms to validate each dispatch...

I'm an experienced react/redux developer, yet I didn't know about those middlewares. Chrome profiler didn't prove very useful, and it took me about 2 hours to nail down the problem.

I suspect other people might have the same problem than me. So what would you think about those middlewares to implement a self timer and raise a warning in the console if they take more than a certain time to run (eg 50ms, ie 20 FPS) ?

@markerikson
Copy link
Collaborator

markerikson commented Mar 6, 2020

Yeah, that seems like a reasonable thing to do.

Can you go ahead and file a PR against the v1.3.0-integration branch to add that?

We can add a config option to both middleware to allow specifying the timeout as well.

@markerikson
Copy link
Collaborator

Done in 1.3.

@LuisGarcia9000
Copy link

I've switched to redux toolkit for a new project built with create react app, and encountered a big performance issue during development. Long story short, I was storing large amounts of json in the store and redux toolkit's default dev middlewares (redux-immutable-state-invariant and serializable-state-invariant-middleware) were taking around 400ms to validate each dispatch...

I'm an experienced react/redux developer, yet I didn't know about those middlewares. Chrome profiler didn't prove very useful, and it took me about 2 hours to nail down the problem.

I suspect other people might have the same problem than me. So what would you think about those middlewares to implement a self timer and raise a warning in the console if they take more than a certain time to run (eg 50ms, ie 20 FPS) ?

@matthieudumas I have the same problem, How do you solved it?

@markerikson
Copy link
Collaborator

@LuisGarcia9000 The dev check middlewares have done that for the last year or so. Also, we recently updated the middlewares in 1.5.x to run much faster in most cases. Please make sure you are using the latest version of RTK (1.6.2+)

@LuisGarcia9000
Copy link

@markerikson I have updated to RTK 1.6.2, but the problem still remains, even though I have placed:

middleware: getDefaultMiddleware => [
    ...getDefaultMiddleware({
      immutableCheck: false,
      serializableCheck: false
    })

¿any siggestion?

@phryneas
Copy link
Member

phryneas commented Nov 5, 2021

You might also want to try immutableCheck: false

@markerikson
Copy link
Collaborator

markerikson commented Nov 5, 2021

@LuisGarcia9000 : can you clarify what actual error you're seeing? You haven't shown any details yet.

It would also help if you can provide info on what kind of data you're putting into the store, how big it is, what sort of actions are being dispatched, etc.

@LuisGarcia9000
Copy link

My probles is this: dispatch this action si too slow, near 4 seg, I only are saving 4 addressess:
image

@markerikson
Copy link
Collaborator

@LuisGarcia9000 Hmm. There's no way that a basic dispatch should be taking 4 seconds, and I strongly doubt that the dev check middleware are the problem here.

Can you please post a repository or CodeSandbox that shows the problem actually happening? It's likely that there's some other problem going on in the app, but I can't say what might be the cause without seeing the actual code.

@LuisGarcia9000
Copy link

@markerikson ok, I'm going to looking for in another place, maybe my configuration.
Thank you very much.

@phryneas
Copy link
Member

phryneas commented Nov 5, 2021

@LuisGarcia9000 configuration would also not be the issue here. Is this maybe an api call that just answers after four seconds?

@LuisGarcia9000
Copy link

@LuisGarcia9000 configuration would also not be the issue here. Is this maybe an api call that just answers after four seconds?

@phryneas I don´t know where is the problem but this is only happen on "development", apk is working very fast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants