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

CacheMap.get calls should await the promised value #319

Open
gabidi opened this issue Oct 31, 2022 · 1 comment
Open

CacheMap.get calls should await the promised value #319

gabidi opened this issue Oct 31, 2022 · 1 comment
Assignees

Comments

@gabidi
Copy link

gabidi commented Oct 31, 2022

dataloader/src/index.js

Lines 88 to 97 in 015a94c

var cachedPromise = cacheMap.get(cacheKey);
if (cachedPromise) {
var cacheHits = batch.cacheHits || (batch.cacheHits = []);
return new Promise(resolve => {
cacheHits.push(() => {
resolve(cachedPromise);
});
});
}
}

Seems like this prevents the use of async calls to centralized caches in it's current implementation since the returned promise will be 'Truthy' even if it resolves with a cache miss (null, undefined).

Wondering if there is a design reason for this, or a PR is welcome ?

@vishalsingh2972
Copy link

@gabidi can you assign this to me if its still open?

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

No branches or pull requests

2 participants