From f00e9fcee5cee6d3f665c89c6c56b605b2200092 Mon Sep 17 00:00:00 2001 From: Geneustace Wicaksono <83039642+SentientPlatypus@users.noreply.github.com> Date: Fri, 2 Oct 2026 14:11:00 -0400 Subject: [PATCH 1/2] Fix stream desync when a non-blocking read hits a partial message handle_incoming_messages(blocking=False) treated a BlockingIOError raised part-way through read_message() as "no messages", discarding the header and payload bytes already consumed. The next read then parsed bytes from the middle of a message as a length header, which surfaces as "Error while unpacking message (0 bytes) ... Invalid offset" and terminates the bot/hivemind/script. Only the first recv of a message is now non-blocking; once any byte has been consumed the rest of the message is read blocking. --- rlbot/interface.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/rlbot/interface.py b/rlbot/interface.py index a4d0d3d..42fcc04 100644 --- a/rlbot/interface.py +++ b/rlbot/interface.py @@ -70,9 +70,6 @@ def __del__(self): def _int_to_bytes(val: int) -> bytes: return val.to_bytes(2, byteorder="big") - def _read_int(self) -> int: - return int.from_bytes(self._read_exact(2), "big") - def _read_exact(self, n: int) -> bytes: assert self.socket is not None, "Socket has not been established" @@ -88,7 +85,19 @@ def _read_exact(self, n: int) -> bytes: return bytes(buff) def read_message(self) -> bytes: - size = self._read_int() + assert self.socket is not None, "Socket has not been established" + + # Only this first recv may raise BlockingIOError when the socket is non-blocking. + # Once any byte of a message has been consumed, the rest must be read blocking, + # otherwise the consumed bytes are lost and the stream loses its framing. + header = self.socket.recv(2) + if len(header) == 0: + raise EOFError + self.socket.setblocking(True) + + if len(header) == 1: + header += self._read_exact(1) + size = int.from_bytes(header, "big") return self._read_exact(size) def send_bytes(self, data: bytes): From f25807c472a0f5582b7a8f550cb4fa71cd26dc39 Mon Sep 17 00:00:00 2001 From: Geneustace Wicaksono <83039642+SentientPlatypus@users.noreply.github.com> Date: Fri, 2 Oct 2026 15:24:55 -0400 Subject: [PATCH 2/2] Bump version to beta56 --- rlbot/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rlbot/version.py b/rlbot/version.py index b6da448..fa3337d 100644 --- a/rlbot/version.py +++ b/rlbot/version.py @@ -1 +1 @@ -__version__ = "2.0.0-beta.55" +__version__ = "2.0.0-beta.56"