 
     override class func canonicalRequest(for request: URLRequest) -> URLRequest
         {
-        synchronized
+        defer { Self.requestInitialization.decrement() }
+
+        let body = extractBody(from: request)
+
+        let stubs = synchronized { Self.stubs }
+        guard let stub = stubs.first(where: { $0.matcher.matches(request, withBody: body) }) else
             {
-            defer
-                { Self.requestInitialization.decrement() }
-
-            let body = extractBody(from: request)
-
-            let stubs = Self.stubs
-            guard let stub = stubs.first(where: { $0.matcher.matches(request, withBody: body) }) else
-                {
-                fatalError(
-                    """
-                    Unstubbed network request:
-                        \(request.httpMethod ?? "<nil method>") \(request.url?.absoluteString ?? "<nil URL>")
-                        headers: \(request.allHTTPHeaderFields ?? [:])
-                        body: \(body?.description ?? "nil")
-
-                    Available stubs:
-                        \(stubs.map { $0.description }.joined(separator: "\n    "))
-
-                    Halting tests
-                    """)
-                }
-
-            let mutableRequest = request as! NSMutableURLRequest
-            URLProtocol.setProperty(stub, forKey: stubPropertyKey, in: mutableRequest)
-            return mutableRequest as URLRequest
+            fatalError(
+                """
+                Unstubbed network request:
+                    \(request.httpMethod ?? "<nil method>") \(request.url?.absoluteString ?? "<nil URL>")
+                    headers: \(request.allHTTPHeaderFields ?? [:])
+                    body: \(body?.description ?? "nil")
+
+                Available stubs:
+                    \(stubs.map { $0.description }.joined(separator: "\n    "))
+
+                Halting tests
+                """)
             }
+
+        let mutableRequest = request as! NSMutableURLRequest
+        URLProtocol.setProperty(stub, forKey: stubPropertyKey, in: mutableRequest)
+        return mutableRequest as URLRequest
         }
 
     private static func extractBody(from request: URLRequest) -> Data?

    static func clearAll()
        {
        Self.requestInitialization.await
            { stubs = [] }
        }

    override class func canInit(with request: URLRequest) -> Bool


    static func wrap(_ configuration: URLSessionConfiguration) -> URLSessionConfiguration
        {
        configuration.protocolClasses = [Self.self]
        return configuration
        }

