fix(mcp): Prevent initialization hangs and task group leaks
The MCP session initialization used asyncio.wait_for, which runs inside a nested asyncio task. Because the underlying MCP client uses AnyIO internally, exiting the ClientSession context manager inside the nested task triggered a 'Attempted to exit cancel scope in a different task' error, or caused connection initialization to hang. This fix gates initialization under anyio.fail_after when the experimental graceful error handling flag is ON, ensuring context block entry and exit happen inside the same task execution scope. Fixes #5886 Change-Id: Ic81c82175eba3793dfb1f07bcd449acac13b24f2
B
Bo Yang committed
334ef81568675282956c36a54779f09ca643e2c0
Parent: a4fb2ab