-
Notifications
You must be signed in to change notification settings - Fork 169
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
question: How do you destroy a scoped container? #739
Comments
Hi @mzyrc, which version are you using? |
Hey @attilaorosz I'm using 0.10.0 with node 16.13.2 |
Hi @attilaorosz Any update on this? |
@mzyrc sorry for the late reply. Could you please provide a repro repo to see how you create the scoped container? |
No problem at all! Here's a link to a spike I've put together that simulates the issue - https://github.com/mzyrc/typedi-memory-leak Let me know if I can provide anymore information or if anything is unclear |
@mzyrc Thanks for the detailed report! So it seems like the container registry is not released yet so unfortunately there is no official way to dispose of a container (that i know of). There is a workaround tho: const index = Container['instances'].findIndex((instance: any) => instance.id === containerId);
if (index > -1) {
Container['instances'].splice(index, 1);
} This is obviously very hacky, but if you have a critical project needing this right now, there you go. @NoNameProvided Do you have a schedule for the next release? |
Hi @attilaorosz Thanks for such a quick turn around, I can confirm the workaround worked great 👍 If I can help at all with the upcoming release I'd be happy to lend a hand |
@attilaorosz @NoNameProvided is this fixed in the latest version ? Will doing |
I'm currently using typedi in an HTTP application and I'm creating a scoped container per request to ensure there's no bleed from other requests that are in flight.
At the end of the request I call
.reset()
on the scoped container and I also set the scoped container tonull
. However, when profiling the application with Chrome Dev Tools I can see that the container instances are still in memory and even after calling.reset()
I'm still able to retrieve different container instances back with.get()
.I'm just wondering if I'm missing something or perhaps my usage of typedi is incorrect?
The text was updated successfully, but these errors were encountered: