remotestorage.js
remotestorage.js copied to clipboard
getAll promise doesn't return data
After connecting to my storage when the getAll promise is fulfilled I get an object like
{
id1: true,
id2: true
}
not the real data. Then remote events are triggered containing the real data. I expected to get the real data right away and no remote events from that data being triggered.
hm, sounds like a bug
reproduced
actually, it turns out it works as intended, but the situation is a bit more complicated:
- for all items that are not strings, it will fill in
true - for all strings that are not valid JSON, it will also fill in
true - for all JSON strings that do not represent objects, it will also fill in
true - for all JSON strings that do represent objects, it will fill in that object
By the way, we had an option once for only getting objects of a certain type/schema. I think we should re-add that asap, right?
The behavior is different when I just refresh the page. Then I get data. Only after connecting I get true. I should have stringified objects btw.
Could you show us some code? I haven't encountered this issue in my apps yet, and I'm certainly requesting data after connecting.
https://github.com/xMartin/grouptabs/blob/1e12a3bdcf45ee4ab68609bda317a0b781ea33cb/js/app/app.js#L37
Does that happen both when being connected as well as disconnected? I'm still not using anon mode in my app, and you're doing the getAll before the connected event. Maybe it even connects while doing that and there's some race condition bug in the library.
We'll have to investigate using your code. Thanks for posting it!
To try it out I would disconnect, create some data and then refresh the page?
Exactly. The question is if it only happens when loading the page while rs.js is connecting.
When I create data in anonymous mode and then connect getAll returns the anonymously created data only, then events are fired for the remote data.
Oh, good one. As the data is younger than the default maxAge, it will not fetch new objects with getAll, but only emit change events for them. However, directly after connecting, I'd expect to get all data from the remote as well.
Should we add an issue for a new feature? More opinions?
Any news here? I think this is a very basic thing that doesn't behave as expected.
oh sorry, this issue should have been reopened
When I create data in anonymous mode and then connect getAll returns the anonymously created data only, then events are fired for the remote data.
Will try to reproduce that tomorrow
oh right, I think we should add timestamp zero to everything that is created or updated in anonymous mode, so that the timestamps really represent the time when data was synced with the remote.
created https://github.com/remotestorage/remotestorage.js/issues/756 about this
I don't think we should close this, the other issue you opened may end up fixing this, but lets leave this open until the problem that @xMartin describes is resolved.
Good point, and this is also actually the case; the timestamps on local changes were only part of the problem; this is still not fixed now because of https://github.com/remotestorage/remotestorage.js/issues/759
This is still the same issue, right?
/cc @michielbdejong @silverbucket @xMartin