π The fast, Pythonic way to build MCP servers and clients.
Fix unawaited coroutine warning and treat as test error (#2806)
Jeremiah Lowinda965db5cb46
diff --git a/pyproject.toml b/pyproject.tomlindex 6b41c1ae3..22fdd6b68 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -110,6 +110,9 @@ filterwarnings = [# Suppress OAuth in-memory token storage warnings in tests# Tests intentionally use ephemeral storage; this warning is for end users"ignore:Using in-memory token storage:UserWarning",+ # Treat unawaited coroutine warnings as errors - these are almost always bugs+ "error:coroutine .* was never awaited:RuntimeWarning",+ "error:Exception ignored in.*coroutine:pytest.PytestUnraisableExceptionWarning",]timeout = 5env = [diff --git a/src/fastmcp/client/client.py b/src/fastmcp/client/client.pyindex 4b8488280..910b6d998 100644--- a/src/fastmcp/client/client.py+++ b/src/fastmcp/client/client.py@@ -686,6 +686,8 @@ class Client(Generic[ClientTransportT]):# If session task already failed, raise immediatelyif session_task.done():+ # Close the coroutine to avoid "was never awaited" warning+ coro.close()exc = session_task.exception()if exc:raise exc