Skip to content

Commit 6408135

Browse files
committed
fix: make PlayolaNetworkLoggingSession Sendable
Addresses PR review (P2): the wrapper crosses actor boundaries (@mainactor PlayolaStationPlayer awaits data(for:)), so declare explicit Sendable conformance. The sound fix constrains the wrapped base to 'any URLSessionProtocol & Sendable' (URLSession already conforms) rather than papering over a non-Sendable stored property. Test doubles passed to the wrapper are marked Sendable accordingly.
1 parent 25b685d commit 6408135

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

Sources/PlayolaCore/Protocols/PlayolaNetworkLoggingSession.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import Foundation
1414
/// session returns and rethrows any error unchanged — it never swallows or
1515
/// alters the result. When ``PlayolaNetworkLogger/handler`` is `nil` no event
1616
/// is built and the wrapper adds negligible overhead.
17-
public struct PlayolaNetworkLoggingSession: URLSessionProtocol {
18-
private let base: URLSessionProtocol
17+
public struct PlayolaNetworkLoggingSession: URLSessionProtocol, Sendable {
18+
private let base: any URLSessionProtocol & Sendable
1919
private let dateProvider: DateProviderProtocol
2020

2121
public init(
22-
wrapping base: URLSessionProtocol,
22+
wrapping base: any URLSessionProtocol & Sendable,
2323
dateProvider: DateProviderProtocol = DateProvider.shared
2424
) {
2525
self.base = base

Tests/PlayolaPlayerTests/PlayolaNetworkLoggingSessionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private final class QueueDateProvider: Sendable, DateProviderProtocol {
3030

3131
/// A session that always throws, to verify error pass-through.
3232
private struct ThrowingURLSession: URLSessionProtocol {
33-
let error: Error
33+
let error: any Error & Sendable
3434
func data(for request: URLRequest) async throws -> (Data, URLResponse) { throw error }
3535
}
3636

Tests/PlayolaPlayerTests/Test Utilities/MockUrlSession.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Foundation
88

99
@testable import PlayolaPlayer
1010

11-
class MockURLSession: URLSessionProtocol {
11+
final class MockURLSession: URLSessionProtocol, @unchecked Sendable {
1212
var responses: [(Data, URLResponse)] = []
1313
var requestCallCount = 0
1414
var lastRequest: URLRequest?

0 commit comments

Comments
 (0)