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

indexdb caching sometimes returns wrong values #74

Open
belst opened this issue Sep 23, 2021 · 1 comment
Open

indexdb caching sometimes returns wrong values #74

belst opened this issue Sep 23, 2021 · 1 comment

Comments

@belst
Copy link

belst commented Sep 23, 2021

Hi, I noticed that sometimes I get wrong values from the cache when I query stuff back to back.
This might be because I am using #72 already.

this.item = await this.api.gw2api.items().get(this.itemId);
console.log(`Itemid: ${this.itemId}`, this.item);
const tpval = await this.api.gw2api.commerce().prices().get(this.itemId);

Sometimes if this gets called a 2nd time the log output will be of the commerce api return not the item.

I haven't looked deeper into it yet, just wanted to let you know. I believe that it is a bug in the autoBatch function.

@ShinyMeta
Copy link

was able to reproduce in test case under following conditions:

  • autobatching is enabled on client, via client.autobatch()
  • endpoint created from client does not call .schema()/.language()/.authenticate()/.autoBatch() any time before calling .get()/.many()
  • in this case, setupAutoBatchSharedData() is only called in the constructor of AbstractEndpoint, which does not have url property set yet
  • this means _cacheHash() would assign all queued requests to the same shared batch... leading to mixed endpoint results.
  • proposed fix separates these batch queues by constructor name and appears to work.

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

No branches or pull requests

3 participants