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

Cache not updating #1188

Closed
rosano opened this issue Jul 9, 2020 · 11 comments
Closed

Cache not updating #1188

rosano opened this issue Jul 9, 2020 · 11 comments

Comments

@rosano
Copy link
Contributor

rosano commented Jul 9, 2020

I have noticed for months a somewhat difficult to replicate bug where some objects tend to not sync to every device – for example, I create several documents on Device A and only some of them appear on Device B. It might be when creating many documents in a shorter period (like once when I created twenty documents and only a dozen or so appeared on other devices). Currently observing this in my flashcards app where an entire deck of card objects is not appearing on one device after days of making changes and adding child objects. I wonder if this is because the corresponding deck folder for 01ECKAHNGHTDKDJK2WJ7A7G7DC in local.itemsMap is listed as false:

Screen Shot 2020-07-09 at 10 00 12

I have been setting maxAge ubiquitously to false to always read from cache, and I use caching.enable('/kommit/') which I believe translates to using the ALL strategy of 'keep a local copy of everything and update as necessary'. I don't understand why certain documents get stuck in this state. I can even edit the document on Device A to trigger some changes but it still doesn't appear on Device B. I usually disconnect and re-connect storage, or delete and re-create the document to get around this, but I'm wondering if there's a way to force the cache to 'get whatever isn't local' even after selecting the ALL strategy?


As an aside, in the screenshot above there seem to be six folders (or six 'decks') but there are currently only three:

Screen Shot 2020-07-09 at 09 57 29

I'm wondering if this is a bug or because I have done something strange with caching.

@raucao
Copy link
Member

raucao commented Jul 9, 2020

This sounds very much related to #1187

@rosano
Copy link
Contributor Author

rosano commented Jul 9, 2020

Right! I had assumed that #1187 was specifically about files or something different than JSON objects but perhaps it's the same thing. If you want me to close this one let me know.

@raucao
Copy link
Member

raucao commented Jul 9, 2020

I'm wondering if there's a way to force the cache to 'get whatever isn't local' even after selecting the ALL strategy?

That's actually the default for the GET functions. maxAge means to check if anything was added remotely since maxAge, then sync those changes first, before returning the up-to-date item or items.

@rosano
Copy link
Contributor Author

rosano commented Jul 19, 2020

I tried toggling cache.disable and cache.enable, but it seemed to have no effect on the visibility of this stuck object.

I tried running client.flush, I'm not sure anymore if this had an effect because I had to start from scratch and lost the stuck state. I tried it on a path with no issues and it seemed to have cleared it from local storage. Was able to get it back via cache.enable.

It seemed that the items listed as false don't appear in client.getListing so you need to call client.flush and cache.enable on the parent directory. If anyone knows how to get the data back into this 'listed as false' state please let me know.

@rosano
Copy link
Contributor Author

rosano commented Jul 14, 2021

re: #1187

It might also occur because I use Safari on macOS and iOS, and as we know Safari has problems.

i just synced a large number of items to firefox after not logging in for a few days and noticed that they seem to be there as expected, including after a refresh. hard to know if it's 'in the state where this issue normally happens' (which i have not been able to define until now) but i think this means my issues are a safari bug. will err on closing this. not sure about the other issue.

@rosano rosano closed this as completed Jul 14, 2021
@rosano
Copy link
Contributor Author

rosano commented Jul 14, 2021

ok, i had initially tried it in hyperdraft. i just tried the same thing in joybox (syncing after a few weeks, lots of changes coming in) and after refreshing the page (maybe too soon) it seems like i'm missing some documents. if i create a new document in safari, wait for the sync, and then refresh the page, the new document remains. but other ones remain invisible after sync. not sure what to make of any of this.

@raucao
Copy link
Member

raucao commented Jul 15, 2021

What does "invisible" mean in that case?

@rosano
Copy link
Contributor Author

rosano commented Jul 15, 2021

not accessible via the app, may or may not be in indexeddb but the i think app either doesn't receive it or receives the object as "true" when loading from cache.

@raucao
Copy link
Member

raucao commented Jul 15, 2021

Without knowing the state of the object in IndexedDB at that time, it's not really possible to debug I'm afraid. Some kind of reproducible test case would be extremely useful.

@rosano
Copy link
Contributor Author

rosano commented Jul 15, 2021

just tried getting /wikiavec/kvc_notes/.

on firefox:

{
 common: {
  itemsMap: {
   // all keys are `true`
  },
 },
}

on safari:

{
 common: {
  itemsMap: {
   // all keys are `true`
  },
 },
 local: {
  itemsMap: {
   // most keys (from the first sync) are `true`
   // the more recent ones 'invisible' ones are `false`
  },
 },
}

i still don't know how to reproduce this state, other than 'use it a lot with safari on multiple devices and after a while newly synced items will become false on the receiving client unless it is touched on the receiving client'

@rosano
Copy link
Contributor Author

rosano commented Jul 15, 2021

sorry i just edited this like 4 times, please see the latest version on github

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

No branches or pull requests

2 participants