From 7e5b77357b849123ff8a096eee5a1b446eced35b Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Wed, 8 Apr 2026 19:06:02 -0400 Subject: [PATCH] tui/local_server: add oauth timeout --- tui/local_server.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tui/local_server.py b/tui/local_server.py index 58dfa0c..4fc4b4e 100644 --- a/tui/local_server.py +++ b/tui/local_server.py @@ -5,7 +5,7 @@ import asyncio from aiohttp import web -async def wait_for_callback(port: int = 23847) -> dict: +async def wait_for_callback(port: int = 23847, timeout: float = 90.0) -> dict: """Start a local server and wait for the OAuth callback. Returns dict with 'code', 'state', and 'iss' from the callback query params. @@ -39,7 +39,12 @@ async def wait_for_callback(port: int = 23847) -> dict: ) from e try: - await event.wait() + try: + await asyncio.wait_for(event.wait(), timeout=timeout) + except asyncio.TimeoutError: + raise RuntimeError( + f"Timed out waiting for OAuth callback after {int(timeout)}s." + ) from None finally: await runner.cleanup() -- 2.51.2