Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
TishSerg opened this issue May 9, 2025 · 1 comment · May be fixed by #1643
Open

Comments

@TishSerg
Copy link

TishSerg commented May 9, 2025

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

@TishSerg TishSerg changed the title SshException check can yield a wrong result SshException check yields a wrong result during normal run, but not while stepping in debugger May 9, 2025
@Rob-Hague Rob-Hague linked a pull request May 11, 2025 that will close this issue
@Rob-Hague
Copy link
Collaborator

Thanks, I have put up a change to fix the weirdness in this method and the error handling in SftpClient.UploadFile

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 a pull request may close this issue.

2 participants