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

NHibernate.Engine.ActionQueue.ExecuteAsync hides TaskCanceledException #3592

Open
Madajevas opened this issue Jul 29, 2024 · 1 comment
Open
Assignees

Comments

@Madajevas
Copy link

If provided cancellation token gets cancelled during execution of InnerExecuteAsync method and any listener code checks token and throws exception it gets lost because regardless of cancellation token state finally block gets executed where PreInvalidateCachesAsync method checks token again and throws exception of its own. I would advice to not call that method if cancellation was requested and allow exception to bubble.

public async Task ExecuteAsync(IExecutable executable, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
try
{
await (InnerExecuteAsync(executable, cancellationToken)).ConfigureAwait(false);
}
finally
{
await (PreInvalidateCachesAsync(cancellationToken)).ConfigureAwait(false);
}
}

@hazzik
Copy link
Member

hazzik commented Jul 29, 2024

Thanks. Good catch.

@maca88, we would probably need to change the async generator to account for this situations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants