From 7292c2785ef6ebf83ae3e3368f4f022415f7892e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigurd=20Lj=C3=B8dal?= <544451+ljodal@users.noreply.github.com> Date: Fri, 14 Nov 2025 14:50:24 +0100 Subject: [PATCH] Cancel l2cap connection result future on abort This cancels the `connection_result` future of LeCreditBasedChannel when abort() is called, e.g. if the LE connection disconnects. This makes it possible for code waiting for a connection to open to detect that the connection has failed. Fixes google/bumble#825 --- bumble/l2cap.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bumble/l2cap.py b/bumble/l2cap.py index 1a5b8d38..f770866e 100644 --- a/bumble/l2cap.py +++ b/bumble/l2cap.py @@ -1149,6 +1149,9 @@ class LeCreditBasedChannel(utils.EventEmitter): def abort(self) -> None: if self.state == self.State.CONNECTED: self._change_state(self.State.DISCONNECTED) + if self.state == self.State.CONNECTING: + if self.connection_result is not None: + self.connection_result.cancel() def on_pdu(self, pdu: bytes) -> None: if self.sink is None: