Skip to content

Conversation

@rolfbjarne
Copy link
Member

Hopefully fixes this test failure:

[FAIL] DisposeAndRecreateBackgroundSessionHandler :   Second request exception
  Expected: null
  But was:  <System.Net.Http.HttpRequestException: Could not communicate with background transfer service
  ---> Foundation.NSErrorException: Error Domain=NSURLErrorDomain Code=-996 "Could not communicate with background transfer service" UserInfo={_NSURLErrorRelatedURLSessionTaskErrorKey=(
       "BackgroundDataTask <FE008EA4-3168-4E2F-B066-9565EEC47E67>.<1>"
      ), NSLocalizedDescription=Could not communicate with background transfer service, _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundDataTask <FE008EA4-3168-4E2F-B066-9565EEC47E67>.<1>}
  --- End of inner exception stack trace ---
  at System.Net.Http.NSUrlSessionHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in /Users/builder/azdo/_work/4/s/macios/src/Foundation/NSUrlSessionHandler.cs:line 595
  at System.Net.Http.HttpClient.GetByteArrayAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
  at MonoTests.System.Net.Http.NSUrlSessionHandlerTest.<>c.<<DisposeAndRecreateBackgroundSessionHandler>b__0_1>d.MoveNext() in /Users/builder/azdo/_work/1/s/macios/tests/monotouch-test/System.Net.Http/NSUrlSessionHandlerTest.cs:line 47
  --- End of stack trace from previous location ---
  at TestRuntime.TryRunAsync(TimeSpan timeout, Task startTask, Task completionTask, UIImage imageToShow, Exception& exception) in /Users/builder/azdo/_work/1/s/macios/tests/common/TestRuntime.RunAsync.cs:line 119>
  at MonoTests.System.Net.Http.NSUrlSessionHandlerTest.DisposeAndRecreateBackgroundSessionHandler() in /Users/builder/azdo/_work/1/s/macios/tests/monotouch-test/System.Net.Http/NSUrlSessionHandlerTest.cs:line 60

…ssionHandler if the background session is in use.

Hopefully fixes this test failure:

    [FAIL] DisposeAndRecreateBackgroundSessionHandler :   Second request exception
      Expected: null
      But was:  <System.Net.Http.HttpRequestException: Could not communicate with background transfer service
      ---> Foundation.NSErrorException: Error Domain=NSURLErrorDomain Code=-996 "Could not communicate with background transfer service" UserInfo={_NSURLErrorRelatedURLSessionTaskErrorKey=(
           "BackgroundDataTask <FE008EA4-3168-4E2F-B066-9565EEC47E67>.<1>"
          ), NSLocalizedDescription=Could not communicate with background transfer service, _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundDataTask <FE008EA4-3168-4E2F-B066-9565EEC47E67>.<1>}
      --- End of inner exception stack trace ---
      at System.Net.Http.NSUrlSessionHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in /Users/builder/azdo/_work/4/s/macios/src/Foundation/NSUrlSessionHandler.cs:line 595
      at System.Net.Http.HttpClient.GetByteArrayAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
      at MonoTests.System.Net.Http.NSUrlSessionHandlerTest.<>c.<<DisposeAndRecreateBackgroundSessionHandler>b__0_1>d.MoveNext() in /Users/builder/azdo/_work/1/s/macios/tests/monotouch-test/System.Net.Http/NSUrlSessionHandlerTest.cs:line 47
      --- End of stack trace from previous location ---
      at TestRuntime.TryRunAsync(TimeSpan timeout, Task startTask, Task completionTask, UIImage imageToShow, Exception& exception) in /Users/builder/azdo/_work/1/s/macios/tests/common/TestRuntime.RunAsync.cs:line 119>
      at MonoTests.System.Net.Http.NSUrlSessionHandlerTest.DisposeAndRecreateBackgroundSessionHandler() in /Users/builder/azdo/_work/1/s/macios/tests/monotouch-test/System.Net.Http/NSUrlSessionHandlerTest.cs:line 60
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds handling for intermittent test failures in NSUrlSessionHandlerTest.DisposeAndRecreateBackgroundSessionHandler when the background transfer service is already in use by another process. The test now ignores these transient failures instead of failing.

Changes:

  • Added a helper method to detect and ignore the specific NSUrlError.BackgroundSessionInUseByAnotherProcess exception
  • Integrated the helper method into both request validation points in the test

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne enabled auto-merge (squash) January 23, 2026 00:27
@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #35a2421] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 35a24218df7dc6b052ef7b19e1508a4d25282219 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #35a2421] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 35a24218df7dc6b052ef7b19e1508a4d25282219 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #35a2421] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 35a24218df7dc6b052ef7b19e1508a4d25282219 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #35a2421] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 35a24218df7dc6b052ef7b19e1508a4d25282219 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #35a2421] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 35a24218df7dc6b052ef7b19e1508a4d25282219 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #35a2421] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 35a24218df7dc6b052ef7b19e1508a4d25282219 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #35a2421] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: 35a24218df7dc6b052ef7b19e1508a4d25282219 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #35a2421] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: 35a24218df7dc6b052ef7b19e1508a4d25282219 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 35a24218df7dc6b052ef7b19e1508a4d25282219 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #35a2421] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 117 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. [attempt 3] Html Report (VSDrops) Download
✅ linker: All 44 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (iOS): All 9 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (tvOS): All 9 tests passed. [attempt 4] Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. [attempt 3] Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. [attempt 2] Html Report (VSDrops) Download

Pipeline on Agent
Hash: 35a24218df7dc6b052ef7b19e1508a4d25282219 [PR build]

@rolfbjarne rolfbjarne merged commit 6bcf0b3 into main Jan 23, 2026
45 checks passed
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 this pull request may close these issues.

4 participants