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.
This commit is contained in:
landaun
2026-08-11 09:13:01 -04:00
committed by kshitij
parent c0106e50e7
commit 0cf48bca25

View File

@@ -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)