                 self.log?("Discovered \(self.cache.peripherals.count) peripherals")
             }
         }) { continuation in
-            self.async {
+            self.async { [unowned self] in
                 self.stopScan()
-                // disconnect all first
-                self._disconnectAll()
-                // queue scan operation
-                let operation = Operation.Scan(
-                    services: services,
-                    filterDuplicates: filterDuplicates,
-                    continuation: continuation
-                )
-                self.continuation.scan = operation
-                self.execute(operation)
+            }
+            Task {
+                await self.disconnectAll()
+                self.async { [unowned self] in
+                    // queue scan operation
+                    let operation = Operation.Scan(
+                        services: services,
+                        filterDuplicates: filterDuplicates,
+                        continuation: continuation
+                    )
+                    self.continuation.scan = operation
+                    self.execute(operation)
+                }
             }
         }
     }


fileprivate extension DarwinCentral.PeripheralContinuationContext {
    
    func didDisconnect() {
        let error = CentralError.disconnected
        while operations.isEmpty == false {
            operations.pop {
                $0.operation.resume(throwing: error)
            }
        }
        notificationStream.values.forEach {
            $0.finish(throwing: error)
        }

        #endif
        return try await withThrowingContinuation(for: peripheral, function: function) { continuation in
            let queuedOperation = QueuedOperation(operation: operation(continuation))
            self.async { [unowned self] in
                self.stopScan() // stop scanning
                let context = self.continuation(for: peripheral)
                context.operations.push(queuedOperation)
            }
