Skip to content

Unobserved task exception bugfix#254

Open
darxis wants to merge 3 commits into
IsNemoEqualTrue:masterfrom
darxis:unobserved-task-exception-bugfix
Open

Unobserved task exception bugfix#254
darxis wants to merge 3 commits into
IsNemoEqualTrue:masterfrom
darxis:unobserved-task-exception-bugfix

Conversation

@darxis

@darxis darxis commented Oct 24, 2024

Copy link
Copy Markdown

This PR fixes issue #253

When calling SqlTableDependency<T>.Stop() method an UnobservedTaskException event is raised, which is not supposed to happen as an application with ThrowUnobservedTaskExceptions set to true would crash when this happens.

This PR removes the redundant call to .WithException(cancellationToken) inside the SqlTableDependency<T>.WaitForNotifications method. It is not needed because the cancellationToken is already passed to the sqlCommand.ExecuteReaderAsync method. When .WithException(cancellationToken) is called and the Stop() method requests a cancellation then the internal task returned from the sqlCommand.ExecuteReaderAsync is not awaited at all (because the internal task created within .WithException(cancellationToken) executes (fails due to cancellation) first.

A test case is also included.

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

Successfully merging this pull request may close these issues.

1 participant