routing-controllers
routing-controllers copied to clipboard
question: How to ensure removing inner containers
I was trying to... Every request coming to my server containing a correlation id. In order to do so I have 2 middlewares.
- A Before middleware that creates a container for the request
Container.of(req.correlationId)
. - An After middleware that removes the container after the request id fulfilled / rejected. The problem: Sometimes the after middleware is not called:
- When an authentication middleware returns status 401 without advancing to the next middleware.
- When error is raised by the controller / service.
In this case I have a leak since the request's container will never be removed.
Do you have a suggestion how can I ensure removing the container (at least for the first case I mentioned).
Thank you.
@TKul6 If you disable the default error handler and implement your own you could destroy your container instance there.
Closing this as stale.
If the issue still persists, you may open a new Q&A in the discussions tab and someone from the community may be able to help.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.