diff --git a/core/src/trezor/wire/thp/channel.py b/core/src/trezor/wire/thp/channel.py index dfe875b6397..d6ce8a28813 100644 --- a/core/src/trezor/wire/thp/channel.py +++ b/core/src/trezor/wire/thp/channel.py @@ -247,7 +247,7 @@ async def recv_payload( if expected_ctrl_byte is None or not expected_ctrl_byte(ctrl_byte): if __debug__: - self._log("Unexpected control byte", utils.hexlify_if_bytes(msg)) + self._log("Unexpected control byte: ", utils.hexlify_if_bytes(msg)) raise ThpError("Unexpected control byte") # 2: Handle message with unexpected sequential bit diff --git a/core/src/trezor/wire/thp/session_context.py b/core/src/trezor/wire/thp/session_context.py index 0c23bb70a7c..6253a011713 100644 --- a/core/src/trezor/wire/thp/session_context.py +++ b/core/src/trezor/wire/thp/session_context.py @@ -56,14 +56,15 @@ async def handle(self, message: Message | None = None) -> None: if __debug__: log.exception(__name__, e, iface=self.iface) await self.write(failure(e)) + return except UnexpectedMessageException as unexpected: # The workflow was interrupted by an unexpected message. We need to # process it as if it was a new message... message = unexpected.msg except Exception as exc: - # Log and try again. if __debug__: log.exception(__name__, exc, iface=self.iface) + return async def _read_next_message(self) -> Message: while True: