Skip to content

chore: make NetworkService sendable - WPB-24336#4483

Open
caldrian wants to merge 24 commits intodevelopfrom
chore/improve-sendability-WPB-8907
Open

chore: make NetworkService sendable - WPB-24336#4483
caldrian wants to merge 24 commits intodevelopfrom
chore/improve-sendability-WPB-8907

Conversation

@caldrian
Copy link
Copy Markdown
Contributor

@caldrian caldrian commented Mar 24, 2026

StoryWPB-24336 [iOS] Migrate WireNetwork to Swift 6

Issue

This PR makes NetworkService conform to Sendable by extracting the URLSession's delegate. An URLSessionConfiguration argument is used for creating an url session in production code and for mocks.


Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.
  • Adds/updates automated tests.

UI accessibility checklist

If your PR includes UI changes, please utilize this checklist:

  • Make sure you use the API for UI elements that support large fonts.
  • All colors are taken from WireDesign.ColorTheme or constructed using WireDesign.BaseColorPalette.
  • New UI elements have Accessibility strings for VoiceOver.

@caldrian caldrian changed the title chore: make NetworkService sendable - WPB-8907 chore: make NetworkService sendable - WPB-8907x Mar 24, 2026
@caldrian caldrian changed the title chore: make NetworkService sendable - WPB-8907x chore: make NetworkService sendable - WPB-8907 Mar 24, 2026
Copy link
Copy Markdown
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 updates WireNetwork’s NetworkService to participate in Swift Concurrency by conforming to Sendable (@unchecked), and refactors session setup to remove the error-prone post-init configure(with:) step by injecting URLSession creation via an initializer factory closure.

Changes:

  • Make NetworkServiceProtocol Sendable and mark NetworkService as @unchecked Sendable.
  • Replace configure(with:) with an initializer parameter makeURLSession and update production factories/builders accordingly.
  • Update WireNetwork unit tests/helpers to construct NetworkService using the new initializer.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
wire-ios-sync-engine/Source/UserSession/ZMUserSession/ZMUserSessionBuilder.swift Switches REST/websocket/blacklist NetworkService creation to the new makeURLSession initializer pattern.
WireNetwork/Tests/WireNetworkTests/Network/NetworkService/NetworkServiceTests.swift Updates NetworkService test setup to inject a mock session via makeURLSession.
WireNetwork/Tests/WireNetworkTests/Network/APIService/APIServiceTests.swift Updates API service tests to use the new NetworkService initializer.
WireNetwork/Tests/WireNetworkTests/Helpers/RequestSnapshotter.swift Updates test helper to construct NetworkService using makeURLSession.
WireNetwork/Tests/WireNetworkTests/Authentication/AuthenticationManagerTests.swift Updates auth manager tests to use the new NetworkService initializer.
WireNetwork/Sources/WireNetwork/Network/NetworkService/NetworkService.swift Introduces Sendable conformance and replaces configure(with:) with makeURLSession.
WireNetwork/Sources/WireNetwork/Network/NetworkService/NetworkService+Make.swift Updates factory helpers to build sessions through makeURLSession.
WireNetwork/Sources/WireNetwork/Assembly.swift Updates assembly wiring for apiNetworkService to use makeURLSession.
WireAuthentication/Sources/WireAuthentication/NetworkService+Factory.swift Updates authentication factory to use the new NetworkService initializer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 24, 2026

Test Results

1 581 tests   1 581 ✅  1m 58s ⏱️
  193 suites      0 💤
    3 files        0 ❌

Results for commit 0ad7e88.

♻️ This comment has been updated with latest results.

Summary: workflow run #23738810497
Allure report (download zip): html-report-28881-chore_improve-sendability-WPB-8907

@caldrian caldrian marked this pull request as draft March 24, 2026 19:39
XCTAssertEqual(receivedRequest.url?.absoluteString, backendURL.appendingPathComponent("/foo").absoluteString)
}

// MARK: - URLAuthenticationChallenge
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moved to NetworkServiceSessionDelegateTests.swift

URLCredential(user: "user", password: "password", persistence: .none)
}

static func makeAuthenticationChallenge(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

also moved to NetworkServiceSessionDelegateTests.swift

@caldrian caldrian changed the base branch from develop to chore/delete-unused-files-WPB-8907 March 25, 2026 14:00
Copy link
Copy Markdown
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

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@caldrian caldrian changed the title chore: make NetworkService sendable - WPB-8907 chore: make NetworkService sendable - WPB-8907x Mar 25, 2026
@caldrian caldrian changed the title chore: make NetworkService sendable - WPB-8907x chore: make NetworkService sendable - WPB-8907 Mar 25, 2026
@caldrian caldrian changed the title chore: make NetworkService sendable - WPB-8907 chore: make NetworkService sendable - WPB-24336 Mar 25, 2026
@caldrian caldrian marked this pull request as ready for review March 25, 2026 14:22
Copy link
Copy Markdown
Contributor

@samwyndham samwyndham left a comment

Choose a reason for hiding this comment

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

Great! Interestingly I think there was another reason we needed to pass in the URLSession after the NetworkService was created but that doesn't seem to be the case now.

Base automatically changed from chore/delete-unused-files-WPB-8907 to develop March 30, 2026 08:48
@caldrian caldrian enabled auto-merge March 30, 2026 09:55
@sonarqubecloud
Copy link
Copy Markdown

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.

3 participants