mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-07-21 09:03:02 +02:00
fix(channels): pre-allocate reader.channels to prevent lib corruption
meshcore lib 2.2.21 bug: reader.py line 434 does self.channels = self.channels.extend([...]) which sets self.channels = None (extend returns None). This corrupts ALL subsequent channel message processing. Fix: after getting max_channels from device_info, pre-allocate mc._reader.channels to max_channels slots so the extend path is never triggered. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -178,6 +178,16 @@ class DeviceManager:
|
||||
except Exception as e:
|
||||
logger.warning(f"Could not fetch device_info: {e}")
|
||||
|
||||
# Workaround: meshcore lib 2.2.21 has a bug where list.extend()
|
||||
# return value (None) corrupts reader.channels for idx >= 20.
|
||||
# Pre-allocate the channels list to max_channels to avoid this.
|
||||
reader = getattr(self.mc, '_reader', None)
|
||||
if reader and hasattr(reader, 'channels'):
|
||||
current = reader.channels or []
|
||||
if len(current) < self._max_channels:
|
||||
reader.channels = current + [{} for _ in range(self._max_channels - len(current))]
|
||||
logger.debug(f"Pre-allocated reader.channels to {len(reader.channels)} slots")
|
||||
|
||||
logger.info(f"Connected to device: {self._device_name} "
|
||||
f"(key: {self._self_info.get('public_key', '?')[:8]}...)")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user