                 }
                 // cancel old task
                 if let oldTask = self.continuation.discoverCharacteristics[peripheral] {
-                    oldTask.finish(throwing: CancellationError())
+                    oldTask.resume(throwing: CancellationError())
                     self.continuation.discoverCharacteristics[peripheral] = nil
                 }
                 // notify

    public func discoverServices(
        _ services: Set<BluetoothUUID> = [],
        for peripheral: Peripheral
    ) -> AsyncThrowingStream<Service<Peripheral, AttributeID>, Error> {
        let serviceUUIDs = services.isEmpty ? nil : services.map { CBUUID($0) }
        return AsyncThrowingStream(Service<Peripheral, AttributeID>.self, bufferingPolicy: .unbounded) { [weak self] continuation in
            guard let self = self else { return }
            self.queue.async {
                // get peripheral
                guard let peripheralObject = self.cache.peripherals[peripheral] else {
                    continuation.finish(throwing: CentralError.unknownPeripheral)
                    return
                }
                // check power on
                let state = self.centralManager._state
                guard state == .poweredOn else {
                    continuation.finish(throwing: DarwinCentralError.invalidState(state))
                    return
                }
                // check connected
                guard peripheralObject.state == .connected else {
                    continuation.finish(throwing: CentralError.disconnected)
                    return
                }
                // cancel old task
                if let oldTask = self.continuation.discoverServices[peripheral] {
                    oldTask.finish(throwing: CancellationError())
                    self.continuation.discoverServices[peripheral] = nil
                }
                // discover

            
            // cancel all actions that require an active connection
            self.central.continuation.discoverServices[peripheral]?
                .resume(throwing: CentralError.disconnected)
            self.central.continuation.discoverCharacteristics[peripheral]?
                .resume(throwing: CentralError.disconnected)
            self.central.continuation.readCharacteristic
                .filter { $0.key.peripheral == peripheral }
                .forEach { $0.value.resume(throwing: CentralError.disconnected) }
