[NSUrlSessionHandler] Surface cancelled requests with a better exception. Fixes #25667.#25699
[NSUrlSessionHandler] Surface cancelled requests with a better exception. Fixes #25667.#25699rolfbjarne wants to merge 14 commits into
Conversation
…ion. Fixes #25667. Add a test: that sets up a stalling HTTP server, reads the first byte successfully, then cancels the second ReadAsync via a caller-owned CancellationToken. TODO: * Implement the fix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Localhost server access should be reliable, so there's no need to paper over failures with IgnoreInCI/Inconclusive. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
With Content-Length set, HttpListener may buffer the output until all bytes are written. Switching to chunked transfer encoding ensures the first byte reaches the client immediately, so the first ReadAsync completes and the test can proceed to the cancellation scenario. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…stream-readasync-cancellation-test
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR updates NSUrlSessionHandler’s response stream read behavior so that caller-requested cancellation surfaces as an OperationCanceledException/TaskCanceledException rather than being converted into a TimeoutException (fixing #25667).
Changes:
- Adjusts
NSUrlSessionDataTaskStream.ReadAsynccancellation/timeout exception mapping. - Adds a regression test that reproduces stalled-response reads and asserts caller cancellation surfaces as
OperationCanceledException(or subclass).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/Foundation/NSUrlSessionHandler.cs |
Changes exception behavior when ReadAsync is canceled while polling for incoming data. |
tests/monotouch-test/System.Net.Http/NSUrlSessionHandlerTest.cs |
Adds a TCP-based repro test ensuring caller cancellation during a stalled read yields OperationCanceledException. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…stream-readasync-cancellation-test
…nnect - Dispose HttpResponseMessage and stream to avoid resource leaks and allow the TCP connection to close promptly. - Replace Task.Delay(5 min) stall with reading until the client closes the connection, so the server task exits promptly after the test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…stream-readasync-cancellation-test
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #cfd4f59] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #cfd4f59] Build passed (Build packages) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #cfd4f59] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #cfd4f59] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 207 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Surface cancelled requests with an
TaskCanceledExceptioninstead of aTimeoutException. This makes it easier for consumers to determine what happened.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com
🤖 Pull request created by Copilot
Fixes: #25667