Skip to content

Disposing Connection after closing it with timeout causes deadlock #1759

@lukebakken

Description

@lukebakken

Discussed in #1758

Originally posted by JanEggers January 6, 2025

Describe the bug

[TestMethod]
public async Task DisposeWhileCatchingTimeoutDeadlocksRepro()
{
    var factory = new ConnectionFactory
    {
        UserName = "rabbit",
        Password = "rabbit",
        HostName = "localhost",
        VirtualHost = "/",
        AutomaticRecoveryEnabled = true
    };

    var receiveConnection = await factory.CreateConnectionAsync();
    try
    {
        await receiveConnection.CloseAsync(TimeSpan.Zero);
    }
    catch (Exception e)
    {
    }

    // this blocks forever
    await receiveConnection.DisposeAsync();
}

Reproduction steps

see code

Expected behavior

Dispose should never block it must either throw or work

Additional context

Im currently migrating to version from 6.8.1 to 7.0 but this causes my tests to be stuck.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions