@@ -22,7 +22,7 @@ final class MockURLProtocol: URLProtocol, @unchecked Sendable {
2222 }
2323
2424 override func startLoading( ) {
25- Task {
25+ Task { @ MainActor in
2626 guard let testID = self . request. value ( forHTTPHeaderField: " X-Test-ID " ) else {
2727 throw Error . missedXTestIDHeader
2828 }
@@ -31,18 +31,12 @@ final class MockURLProtocol: URLProtocol, @unchecked Sendable {
3131 }
3232 do {
3333 let ( data, response) = try handler ( self . request)
34- await MainActor . run { [ weak self] in
35- guard let self else { return }
36- self . client? . urlProtocol (
37- self , didReceive: response, cacheStoragePolicy: . notAllowed)
38- self . client? . urlProtocol ( self , didLoad: data)
39- self . client? . urlProtocolDidFinishLoading ( self )
40- }
34+ self . client? . urlProtocol (
35+ self , didReceive: response, cacheStoragePolicy: . notAllowed)
36+ self . client? . urlProtocol ( self , didLoad: data)
37+ self . client? . urlProtocolDidFinishLoading ( self )
4138 } catch {
42- await MainActor . run { [ weak self] in
43- guard let self else { return }
44- self . client? . urlProtocol ( self , didFailWithError: error)
45- }
39+ self . client? . urlProtocol ( self , didFailWithError: error)
4640 }
4741 }
4842 }
0 commit comments