-
-
Notifications
You must be signed in to change notification settings - Fork 656
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
ObjectDisposedException is thrown instead of TaskCancelledException when FtpClient.ConnectAsync() is called with cancelled token #569
Comments
Hi, thanks for this. So can this fix it? At the start of every async method, this snippet:
|
Hi, thanks for taking a look at this. That would fix the specific case where the token passed in is already cancelled (though I would use Based on the documentation it sounds like the recommended pattern is to handle the ObjectDisposedException used to indicate cancellation:
What about something like this?
|
This might solve it. You want me to use this pattern for every method? Or just a change in the internal socket methods? |
It seems to me like it should be used anywhere ObjectDisposedException would be thrown instead of TaskCancelledException when an in-progress operation is cancelled. It seems like would apply anywhere Socket.Close() is used to abort an in-progress operation when it is cancelled (e.g. via EnableCancellation). I'm not familiar enough with the code to know if there are other places where this pattern is used. I also have not looked into how this applies to the .NET Core version of the code. |
FTP OS: N/A
FTP Server: N/A
Computer OS: Windows
FluentFTP Version: 32.3.3
When FtpClient.ConnectAsync() is called with a CancellationToken that has already been cancelled it throws ObjectDisposedException. I was expecting TaskCancelledException.
I discovered this during development while testing the FtpClient's cancellation behavior, but it seems plausible that it could happen in a production app, e.g., if multiple operations are using the same cancellation token and the token happens to be cancelled just before the call to ConnectAsync().
Here's code that reproduces the issue:
Logs :
Here's the exception:
The text was updated successfully, but these errors were encountered: