Handle MessageTooLarge error in router to prevent node crash

When a message exceeds gossipsub's 1 MiB limit, the resulting
RuntimeError("MessageTooLarge") was unhandled in _networking_publish,
causing the entire TaskGroup to fail and crash the node. Now catch
this error and log it, dropping the oversized message gracefully.

Fixes #1296

Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
Alex Cheema
2026-02-17 10:34:22 -08:00
co-authored by Claude Opus 4.6
parent 83af8c63fa
commit c4d24a24e4
+8
View File
@@ -211,6 +211,14 @@ class Router:
pass
except AllQueuesFullError:
logger.warning(f"All peer queues full, dropping message on {topic}")
except RuntimeError as e:
if "MessageTooLarge" in str(e):
logger.error(
f"Message too large for gossipsub on topic {topic} "
f"({len(data)} bytes), dropping message"
)
else:
raise
def get_node_id_keypair(