π OpenHands: AI-Driven Development
APP-240 Fix GitHub webhook timeout issue to prevent client disconnect errors (#11965)
Tim O'Farrella9c76d0ed49d
diff --git a/enterprise/server/routes/integration/github.py b/enterprise/server/routes/integration/github.pyindex d7bf857a3f..204b8297f7 100644--- a/enterprise/server/routes/integration/github.py+++ b/enterprise/server/routes/integration/github.py@@ -1,3 +1,4 @@+import asyncioimport hashlibimport hmacimport os@@ -58,7 +59,8 @@ async def github_events()try:- payload = await request.body()+ # Add timeout to prevent hanging on slow/stalled clients+ payload = await asyncio.wait_for(request.body(), timeout=15.0)verify_github_signature(payload, x_hub_signature_256)payload_data = await request.json()@@ -78,6 +80,12 @@ async def github_events(status_code=200,content={'message': 'GitHub events endpoint reached successfully.'},)+ except asyncio.TimeoutError:+ logger.warning('GitHub webhook request timed out waiting for request body')+ return JSONResponse(+ status_code=408,+ content={'error': 'Request timeout - client took too long to send data.'},+ )except Exception as e:logger.exception(f'Error processing GitHub event: {e}')return JSONResponse(status_code=400, content={'error': 'Invalid payload.'})