Skip to content

Remove ObjectDisposedException as inner exception for connection timeout #1035

Closed
@bgrainger

Description

@bgrainger

Connection timeout is implemented by disposing a TcpClient; after this happens, the ObjectDisposedException is preserved as the InnerException for a MySqlException:

throw new MySqlException(MySqlErrorCode.UnableToConnectToHost, "Connect Timeout expired.", ex);

This was done to provide additional diagnostic information.

Despite the clear outer exception message, this routinely gets reported as an ObjectDisposedException, e.g.,:

This may be exacerbated by monitoring tools reporting the inner exception. (This screenshot from Application Insights is a slightly different inner exception but I think I've seen the same problem with it.)

image

The ObjectDisposedException is really just a detail of how timeout is currently implemented and ultimately not germane to the connection timeout; to avoid potential confusion we should throw a MySqlException with no inner exception. (This is potentially a breaking change if anyone had a catch () when block based on the inner exception.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions