From 0cf48bca2572339c9c4f88882dfa6739d347f99c Mon Sep 17 00:00:00 2001 From: landaun Date: Tue, 11 Aug 2026 09:13:01 -0400 Subject: [PATCH] fix(gateway): run channel-directory write off the event loop atomic_json_write() calls os.fsync(), which blocks until the write reaches stable storage. build_channel_directory() already offloads its builders with asyncio.to_thread (#60794) but still called the persist step directly on the loop, so the Discord heartbeat waited on a disk flush. --- gateway/channel_directory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/channel_directory.py b/gateway/channel_directory.py index da643ba146..23d6f361e1 100644 --- a/gateway/channel_directory.py +++ b/gateway/channel_directory.py @@ -206,7 +206,7 @@ async def build_channel_directory(adapters: Dict[Any, Any]) -> Dict[str, Any]: } try: - atomic_json_write(DIRECTORY_PATH, directory) + await asyncio.to_thread(atomic_json_write, DIRECTORY_PATH, directory) except Exception as e: logger.warning("Channel directory: failed to write: %s", e)