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

Changes collectionRevisions Promise interface #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

beaucollins
Copy link
Contributor

Also addresses an issue with the revisionsCache map. Each channel needs it's own revision cache because object id's are only unique per channel. In the current implementation it's possible that to different channels requesting revisions of the same object id would get there revision histories messed up.

This however introduces an issue with memory management. Cached entries will continue to grow with every revision request with no way to clear the cache until the process quits.

@dmsnell
Copy link
Contributor

dmsnell commented Mar 15, 2018

Thanks for finding and fixing this bug @beaucollins - was it causing problems or did you just find it by audit?

It looks like this doesn't create a separate cache per channel but rather per request to getRevisions - was that intentional? am I wrong in my reading?

on desktop I don't think that we'll have problems with memory by storing the revisions. if we are really concerned about it though we could implement a couple of different mitigations: time-based clearing; use of WeakMap with the right key; etc…

maybe the most appropriate way of handling this is to store the revisions in the BucketStore itself if we could rearrange that data model to hold them. if we did that and persisted the revisions then they would be immediately available through different app sessions without needing to re-request them. in fact, this is a way to get around the revision limit that Simperium enforces, but unreliably so (since maybe you can go back as long as you want in the desktop app but not on the iPhone, for example)

other way I don't think memory concerns are an issue for this PR; do you?

@beaucollins
Copy link
Contributor Author

@dmsnell the problem only came up from reasoning about how the cache would work. Given that simplenote is the only app using this, it is very unlikely there have been any naming collisions between the tags bucket and the notes bucket.

You are correct about the cache. It should be stored as a reference in the channel otherwise it starts with an empty cache for every revision request.

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

Successfully merging this pull request may close these issues.

2 participants