remotestorage.js icon indicating copy to clipboard operation
remotestorage.js copied to clipboard

getAll promise doesn't return data

Open xMartin opened this issue 11 years ago • 19 comments
trafficstars

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.

xMartin avatar Jul 21 '14 11:07 xMartin

hm, sounds like a bug

michielbdejong avatar Jul 21 '14 19:07 michielbdejong

reproduced

michielbdejong avatar Aug 12 '14 10:08 michielbdejong

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

michielbdejong avatar Aug 12 '14 11:08 michielbdejong

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?

raucao avatar Aug 12 '14 11:08 raucao

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.

xMartin avatar Aug 14 '14 15:08 xMartin

Could you show us some code? I haven't encountered this issue in my apps yet, and I'm certainly requesting data after connecting.

raucao avatar Aug 14 '14 16:08 raucao

https://github.com/xMartin/grouptabs/blob/1e12a3bdcf45ee4ab68609bda317a0b781ea33cb/js/app/app.js#L37

xMartin avatar Aug 14 '14 16:08 xMartin

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!

raucao avatar Aug 14 '14 17:08 raucao

To try it out I would disconnect, create some data and then refresh the page?

xMartin avatar Aug 14 '14 17:08 xMartin

Exactly. The question is if it only happens when loading the page while rs.js is connecting.

raucao avatar Aug 14 '14 18:08 raucao

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.

xMartin avatar Aug 14 '14 21:08 xMartin

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?

raucao avatar Aug 15 '14 07:08 raucao

Any news here? I think this is a very basic thing that doesn't behave as expected.

xMartin avatar Sep 08 '14 21:09 xMartin

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

michielbdejong avatar Sep 08 '14 22:09 michielbdejong

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.

michielbdejong avatar Sep 08 '14 22:09 michielbdejong

created https://github.com/remotestorage/remotestorage.js/issues/756 about this

michielbdejong avatar Sep 10 '14 18:09 michielbdejong

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.

silverbucket avatar Sep 10 '14 23:09 silverbucket

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

michielbdejong avatar Sep 12 '14 15:09 michielbdejong

This is still the same issue, right?

/cc @michielbdejong @silverbucket @xMartin

raucao avatar Mar 19 '16 22:03 raucao