-
-
Notifications
You must be signed in to change notification settings - Fork 632
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
Clear shared redux stores when server rendering #780
Comments
@udovenko indicated interest, so I'll flag this one as taken. |
@justin808 Not sure I see the way to reset the store. Each project has its own set of reducers and its own logic for bootstrapping the data to store. So resetting the store state should be individual for each JS server bundle. |
Just clear the global map.
|
You mean clear stores registration completely? Feels like we will loose some benefits form having initiated stores on the next request... |
For the reasons you raised, we don't want any hydrated stores on the next call. |
Ok, I'll see what I can do. Can't promise anything for sure unfortunately... |
@justin808 I've forked them gem and tried to reproduce an issue. But it seems that ReactOnRails creates and re-registers Redux store before every component is renderd on the server. It allways calls To test it a bit more I added
Two components were rendered in the same I think the case I've mentioned in #774 - "As I can remember I've even experienced an issue when store state from previous request was affecting next request. At least I thought that was the reason for my bug that time..." - was when I was creating the store manually from component generator function. If you're insist that the issue still exists, can you please show how to reproduce it? |
@udovenko For any stores being registered, they are 100% created new. I'm concerned that you could have a store that sticks around from the previous request. And the component rendering code might be accidentaly using that store by a different name. So to reproduce:
If Store A's values are still there, then we have an issue. |
Keep in mind that if one is careful to hydrate all the used stores for a given request, then no bug would ever be seen. However, there's certainly some extra memory that could be GC'd. |
Even if the store is stick around from previous request, https://github.com/shakacode/react_on_rails/blob/master/app/helpers/react_on_rails_helper.rb#L346 will replace it with new instance anyway. Am I missing someting? |
@justin808 Ok, I see what do you mean. The purpose for cleaning stores left from previous request is generally for GC only. Because they cannot affect components rendering. |
Or they can affect components rendering due to developer mistake... |
@justin808 PR #785 |
Per #774 (comment), we should clear the redux stores before populating it.
The potential bug is that there are some stores with data from unrelated requests sitting around.
This can chew up memory and lead to other unexpected consequences.
Steps to fix:
result
.See #774 for more details.
The text was updated successfully, but these errors were encountered: