-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
add maxAge option #241
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
add maxAge option #241
Conversation
Thank you for your work on this! I’ll take a look very soon. |
@echenley, wouldn't it delete the INIT action? Won't it affect committing? |
actionsById = { 0: liftAction(INIT_ACTION) };
|
I think the first action should always be |
Actually, I was going to implement the same approach for chrome extension some time ago, but came out with auto-commit for the same reason. We need auto-commiting in the extension as we serialize and send the lifted state object, and don't want it to grow too much. Here we don't have this problem, the performance issue comes only when rendering the monitor. So, I think better to implement it as a composable monitor. In this way we keep lifted state as is, but in the log monitor we get only the last actions, and we can change the maximum allowed actions prop or remove it on the fly (as HMR takes care of it). You may take redux-devtools-filter-actions as an example or extend it as there we also delete actions and states and it is also a kind of filtering. UPDATE: by auto-commiting I mean dispatching |
Interesting. I agree it’s interesting to try doing this as a monitor and compare performance on projects where large amounts of actions accumulate very quickly. (http://erikras.github.io/redux-form is a good example, cc @erikras) |
However, I still think a “rolling log” like this that doesn’t grow memory forever is useful and I’d love to see it as an option here. The PR just needs a little more work to squash the old actions into a single INIT action. |
Yes, it will be useful to keep it here also for persisting state. If we keep it here, wouldn't it be better to pass this limit value as a prop of the created |
What about adding an optional property to the commit action, either an index, or a number of actions to commit which defaults to all? That way any monitor can commit actions explicitly. I'll fiddle with it and see how it feels. Thinking something like: case ActionTypes.COMMIT: {
if (liftedAction.index) {
// commit only up to liftedAction.index
// keep rest of history
} else {
// commit everything
}
} |
@gaearon I updated the code to always keep @zalmoxisus It does seem like HMR doesn't work with this, though it's probably not something that would be changed much. I'd be happy to attempt a different approach in another PR. |
@echenley, thanks for investigating this! After merging, I'll try to get it work with the extension to be able to change the value on the fly. |
Actual: the first 5 actions are skipped because autocommit happened during the error state. Expected: I don’t think actions are ever expected to disappear. I think that auto-committing should only go as far as the last non-erroring action. If a reducer
8000
threw, that action should not be auto-committed until it is fixed. However once it is fixed, auto-commit should take action immediately if we are over |
Also, it seems like we are not taking care of |
Finally, we want to run more tests. A few tests for this specific functionality does not seem enough. We might want to add a copy for every “normal” test that uses |
Thanks for the feedback! Making progress on this. The issue with Here's a gif of the error behavior. I have |
I think the tests are fairly complete now. In |
How's this looking for release? I have an app with hi-frequency actions and this change is exactly what I'm looking for. I tested this branch out and I'm happy to report it fixes my problem. Now I just need a release to point to. Thanks for the good work! |
@echenley any update on merging this? |
Just to note, this solves issues with having an onChange handler tied to the store, which causes the filter monitor to lag the application like crazy after a few seconds of typing normally. Filter solves this as well, but I would prefer both knowing that there is a performance hit after a certain number of messages. It's throwing off testing slightly. |
That’s awesome, thank you for hard work. 👍 |
@echenley I added you as a collaborator. Please feel free to edit the documentation to include information about |
Excellent, thank you! |
I don't know if this is related, but lately I keep getting a lot of maxAge output in the console such as: maxAge 50 50 Is this leftover debugging code? |
@mess0615 This PR didn't introduce any debug statements. Not sure where it's coming from, but it's not this repo. https://github.com/gaearon/redux-devtools/search?utf8=%E2%9C%93&q=console |
@mess0615 looks like it is coming from the Chrome extension https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd |
I am getting these maxAge messages too. Just started today with no apparent relationship to code that I have changed. The messages stop when I disable Redux Dev Tools in Chrome. Found this code in the Chrome tools that seems related.
|
Chrome extension issue zalmoxisus/redux-devtools-extension#89 |
Oh, sorry, just forgot to remove the console log on Chrome extension. It is not related to this PR in any way. UPD: Fixed, |
options
parameter to instrument. OnlymaxAge
property is used currently but could conceivably be used for other options.Usage: