-
-
Notifications
You must be signed in to change notification settings - Fork 957
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
Memory leak when using cache
#1128
Comments
You're creating a new Keyv instance every time (using the |
@sindresorhus I think we should disallow passing raw storage instances and force users to pass a |
That's inconvenient for users just wanting a simple memory cache. Can we not just handle it somehow? |
It can be solved on the Keyv side via a WeakMap. |
A destructor/destroy method can also be added in Keyv that takes care of tear-downs. |
Actually I can solve this in Got, then this issue would be fixed as well as #1098 |
Fixed in 2abacff |
This comment has been minimized.
This comment has been minimized.
The script now gives (I replaced
It just attaches |
Related: jaredwray/keyv#101 |
Reopening as we need to test this with newest |
memory leak const map = new Map();
let response = await got('https://www.youtube.com', { cache: map });
for (let i = 0; i < 1000; i++)
response = await got('https://www.youtube.com', { cache: map }); |
It seems to be fix in cacheable-request version 10.2.6 |
Describe the bug
v12.16.1
macOS 10.15.3
Actual behavior
Getting the following error message when making multiple requests with
got
:Expected behavior
For got/keyv to:
I expect this behavior especially when
.extend
ing:Code to reproduce
got
, andgot
passes that intoKeyv
, which adds the event listener.on
, but in practice I'm using keyv-memcache, which extends the EventEmitter which is what makes the warning about the memory leakChecklist
For what it's worth, I also read #792, https://github.com/lukechilds/cacheable-request/issues/30, and #921 (the "click for solution" link is broken for me) but I believe the problem is different.
The text was updated successfully, but these errors were encountered: