Skip to content
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

Caching ExecuteMethod in the HandlerDefinition cause exceptions in the scoped disposable services. #324

Closed
WahidBitar opened this issue Nov 7, 2022 · 2 comments
Labels
bug Something isn't working fixed the bug has been squashed

Comments

@WahidBitar
Copy link
Contributor

Related to this discord discussion

I ran into a problem related to the CommandHandlers
the following will work totally fine at the first shot.
def.ExecuteMethod ??= def.HandlerType.HandlerExecutor(tCommand, handler);
However, if you have any scoped disposable dependencies like DbContext, they will be disposed after the first execution, and because the ExecuteMethod is cached it will try to reuse them again so you'll get an exception.

if we called the def.HandlerType.HandlerExecutor(tCommand, handler); on each execution the problem will be solved.

does it harm the performance a lot to call the HandlerExecutor on each execution?

@dj-nitehawk dj-nitehawk added bug Something isn't working fixed the bug has been squashed labels Nov 7, 2022
@dj-nitehawk
Copy link
Member

can you try v5.3.2.6-beta
issue is fixed but lost a bit of performance because i couldn't figure out the correct expression tree for the needed logic.
will try again in a couple of days with a fresh mindset.
this will have to do for now.

@dj-nitehawk
Copy link
Member

dj-nitehawk commented Nov 9, 2022

performance recovered with #328

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed the bug has been squashed
Development

No branches or pull requests

2 participants