Skip to content

SshException check yields a wrong result during normal run, but not while stepping in debugger #1640

Closed
@TishSerg

Description

@TishSerg

SSH.NET 2025.0.0

SshException ("Failure") is about to happen as a result of SendRequest(request); call. But by the time if (exception is not null) check is done, the exception variable is still null (because it's set asynchronously after we get the response). So it won't be thrown by throw exception;. That's the case if we just run after breaking on SendRequest(request); line. But if we step over to the if (exception is not null) line, the exception variable gets a chance to be set, and we get that throw exception; executed as it was intended.

This bug makes me unable to catch SshException in my code while using sftpClient.UploadFile().

You can see demos in the GIFs below:

Image

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions