routing-controllers icon indicating copy to clipboard operation
routing-controllers copied to clipboard

question: How to ensure removing inner containers

Open TKul6 opened this issue 4 years ago • 1 comments

I was trying to... Every request coming to my server containing a correlation id. In order to do so I have 2 middlewares.

  1. A Before middleware that creates a container for the request Container.of(req.correlationId).
  2. 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 avatar Sep 14 '20 08:09 TKul6

@TKul6 If you disable the default error handler and implement your own you could destroy your container instance there.

attilaorosz avatar Feb 22 '22 17:02 attilaorosz

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.

attilaorosz avatar Dec 21 '22 15:12 attilaorosz

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.

github-actions[bot] avatar Jan 21 '23 00:01 github-actions[bot]