LinkedDataFragments / Client.js

[DEPRECATED] A JavaScript client for Triple Pattern Fragments interfaces.
http://linkeddatafragments.org/
Other
92 stars 35 forks source link

getFragmentByPattern() doesn't return data for second call #11

Closed warpr closed 9 years ago

warpr commented 9 years ago

Hello Ruben,

When I call client.getFragmentByPattern(pattern); with the same pattern twice I only get results from the first call. From looking at the code it looks like the request is cached, but the iterator for the second response is exhausted and doesn't start at the beginning again.

Am I doing something wrong or is there a bug somewhere?

I have a small example of my problem at:

https://gist.github.com/warpr/75c79510a5b81f3d5e05

RubenVerborgh commented 9 years ago

Hi Kuno, great that you're using this library, and thanks for reporting this. It is definitely a bug.

I'm now investigating the specifics, but it has to do with timing. For us, it's also a common case to request a fragment multiple times. However, your specific bug seems to be triggered when the two fragments are requested immediately in succession; i.e., if you add a timeout on the second call, it behaves as expected. I suspect that some listener reacts too late.

I'll verify this and write a fix.

RubenVerborgh commented 9 years ago

Fixed in the devel branch, will be in the next patch release. Thanks again for spotting this!

warpr commented 9 years ago

Thanks for the super fast fix! I've confirmed it works in my test when I use the develop branch.