Python
fix: preserve exception chain in RelayHub.wait_dispatched
Anuj044328276749c9615
diff --git a/coworker/connectors/relay_client.py b/coworker/connectors/relay_client.pyindex 57fc38cc..f1e7bf1c 100644--- a/coworker/connectors/relay_client.py+++ b/coworker/connectors/relay_client.py@@ -204,10 +204,10 @@ class RelayHub:)try:await asyncio.wait_for(self._progress.wait(), timeout=remaining)- except asyncio.TimeoutError:+ except asyncio.TimeoutError as exc:raise TimeoutError(f"only {self._dispatched} frames dispatched (< {at_least})"- )+ ) from exc# -- default transport ---------------------------------------------------def _default_transport_factory(self) -> RelayTransport:diff --git a/tests/test_slack_relay.py b/tests/test_slack_relay.pyindex b05ce807..5c17fba2 100644--- a/tests/test_slack_relay.py+++ b/tests/test_slack_relay.py@@ -223,6 +223,18 @@ async def test_relay_ignores_own_bot_echo():assert events == []+async def test_wait_dispatched_timeout_preserves_exception_chain():+ """A timed-out wait must chain the original asyncio.TimeoutError, not swallow it."""+ adapter = _adapter([], close_after=False) # no frames ever arrive+ await adapter.connect()+ try:+ with pytest.raises(TimeoutError) as excinfo:+ await adapter.wait_dispatched(1, timeout=0.05)+ assert isinstance(excinfo.value.__cause__, asyncio.TimeoutError)+ finally:+ await adapter.disconnect()++# --- reconnect --------------------------------------------------------------