ObjectDisposedException is thrown instead of TaskCancelledException when FtpClient.ConnectAsync() is called with cancelled token
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- csharp
- Lĩnh vực
- backend, networking
Hướng nghiên cứu
The report traces the failure through FtpClient.ConnectAsync and FtpSocketStream.ConnectAsync, with the exception occurring in FtpSocketStream.EnableCancellation. Start by reading those methods and the existing cancellation tests. Reproduce with an already-cancelled CancellationToken and confirm ConnectAsync reports cancellation instead of ObjectDisposedException; the issue does not name a test file.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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:
private static async Task TestAsync() {
FtpTrace.AddListener(new ConsoleTraceListener());
// This could be cancelled due to multiple operations using the same token, a timeout expiring, etc.
var cancelledToken = new CancellationToken(true);
using (var ftpClient = new FtpClient(new Uri("ftp://127.0.0.1"))) {
await ftpClient.ConnectAsync(cancelledToken);
}
}
Logs :
# ConnectAsync()
Status: Connecting to 127.0.0.1:21
# Dispose()
Status: Disposing FtpClient object...
Status: Disposing FtpSocketStream...
Status: Disposing FtpSocketStream...
Here's the exception:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.
at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at FluentFTP.FtpSocketStream.<EnableCancellation>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at FluentFTP.FtpSocketStream.<ConnectAsync>d__80.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at FluentFTP.FtpClient.<ConnectAsync>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at FluentFTP.FtpClient.<ConnectAsync>d__27.MoveNext()
[...non FtpClient stack traces omitted...]
- Ngôn ngữ chính
- C#
- Star
- 3.4k
- Fork
- 684
- Merge trung bình
- 3 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của robinrodricks/FluentFTP
-
enhancement help wanted major
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
robinrodricks/FluentFTP#1889 · 3 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
robinrodricks/FluentFTP#1887 ·
-
.NET maintenance response requested
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
robinrodricks/FluentFTP#1886 · 7 bình luận ·
-
bug fixed Pending next release pureftpd-server workaround
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 57/100
robinrodricks/FluentFTP#1878 · 12 bình luận ·
-
incorrect usage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 50/100
robinrodricks/FluentFTP#1859 · 4 bình luận ·
Tất cả issue của robinrodricks/FluentFTP
Issue tương tự
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
dotnet/maui#40788 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
erkamyaman/rust-anything#943 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
SixLabors/ImageSharp.Drawing#438 · 1 bình luận ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100