question: How do you destroy a scoped container?
See original GitHub issueIā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 to null. 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?
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Spring - How can I destroy my prototype-scoped beans?
Spring will create the prototype bean required by your code, but will not destroy it. This behaviour is by design as it is...
Read more >Object Lifetime Management ā Simple Injector 5 documentation
Instances will be disposed when the container is disposed. Many different platform and framework-specific flavors are available for the Scoped lifestyle. PleaseĀ ...
Read more >Service Lifetimes in a Nutshell - { Between Two Brackets }
When we create our service container and reference a scoped provider instance, the service scope in reference will internally call Dispose atĀ ...
Read more >Introduction to Contexts and Dependency Injection - Quarkus
Well, a bean is a container-managed object that supports a set of basic services, ... What scopes can I actually use in my...
Read more >Dependency Injection and Service Lifetimes in .NET Core
NET Core has a native Dependency Injection container, but you can also use another ... Scoped ā Services are created on each request...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@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:
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