-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Cache and pMemoizeClear bug #55
Comments
Probably related to #36 |
@sindresorhus This bug happens because between two |
Yes. The only solution I can think of is to have some kind of lock to make sure that no other cache operation are executed during that time. |
I wonder if something like this would solve it: if (cache && await cache.has(key)) {
const [has, value] = await Promise.all([cache.has(key), cache.get(key)]);
if (has) {
return value;
}
} It would call |
Yep, this is working solution. For my project calling |
I’m not sure this is a bug. You’re starting an async operation and immediately aborting it before it resolved. The only issue I see is that this probably leads to a race condition between cached calls and new calls. |
@fregante this bug for async app like web server with multiple parallel incoming requests. |
You want pending checks to be treated differently from completed checks. I’d classify this as a feature request rather than a bug. If I call “clear cache” I expect the cache to be cleared. Imagine if a pending browser request reinstated the previous cookie after the user cleared the cache, finding themselves still logged in.
|
Hi, great module!
I found interesting bug with
pMemoizeClear
and cache.Here is example:
It's connected with these two lines
p-memoize/index.ts
Lines 104 to 105 in 52fe605
if I remove
await
inif
condition, result will besomething
as expected.I'm not sure how to fix this issue, perhaps you have better ideas than me 😉
The text was updated successfully, but these errors were encountered: