Slack

We’re All Just Looking for Connection

Oct 10, 2024
We’re All Just Looking for Connection
SummaryAI, from the source post

This post details the resolution of a critical bug that stalled the asyncio runtime migration. The bug stemmed from incorrect implementations of `closed()` and `is_connected()` in the `AsyncioConnection` class, which failed to accurately detect when TCP connections were closed by the remote end (e.g., database proxies or RPC services). This led to `EOFError` during SQL queries and hung requests during PDF export RPC calls. The investigation revealed subtle TCP state management issues, including the `CLOSE_WAIT` state and the behavior of `asyncio.StreamWriter.is_closing()`. The fixes involved correcting these methods to properly detect connection closure, which in turn unblocked the final deployment of asyncio across all services.