Skip to content

Commit

Permalink
Fix very rare deadlock
Browse files Browse the repository at this point in the history
Fixes #1751

Attempt to fix deadlock by waiting on channel dispatcher first, then channel reader.
  • Loading branch information
lukebakken committed Feb 5, 2025
1 parent 51d1eeb commit 6a627dd
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,17 @@ public async Task WaitForShutdownAsync()
{
try
{
await _reader.Completion
.ConfigureAwait(false);
await _worker
.ConfigureAwait(false);

/*
* rabbitmq/rabbitmq-dotnet-client#1751
*
* Wait for the worker first to ensure all items have been read out of the channel,
* otherwise the following will never return (https://stackoverflow.com/a/66521303)
*/
await _reader.Completion
.ConfigureAwait(false);
}
catch (AggregateException aex)
{
Expand Down

0 comments on commit 6a627dd

Please sign in to comment.