jaredwray/cacheable

Memory leak

Closed this issue · 4 comments

GalRab commented

We have a memory leak when there is a lot of concurrency requests, the memory is raised until the container crashed.
It cause by this line:
cachek.once('error', errorHandler); // src/index.ts

I noticed there was a commit (line 209) that changed the behavior when the listener is removed.

Why did it change to remove the listener on error rather than on response?
Does the listener never remove if there is no error?

@GalRab - looking into this as I believe this was changed do to the way we are handling the response.

I created a new branch with a fix that would remove both. https://github.com/jaredwray/cacheable-request/tree/fixing-listener-memory-leak---issue-%23222

Can you validate that this resolves the issue?

GalRab commented

I created a new branch with a fix that would remove both. https://github.com/jaredwray/cacheable-request/tree/fixing-listener-memory-leak---issue-%23222

Can you validate that this resolves the issue?

yes, it seems to have resolved the issue