-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
backendBackend Task (python)Backend Task (python)bugSomething isn't workingSomething isn't workingperformance
Description
Problem
backend/utils/webhooks.py has two async def functions that make synchronous requests.post() calls:
realtime_transcript_webhook()(line 108) — called on every real-time transcript segmentsend_audio_bytes_developer_webhook()(line 155) — called for audio byte streaming
These blocking calls stall the entire asyncio event loop while waiting for the external webhook endpoint to respond (up to 15s timeout). During that time, all other concurrent WebSocket connections and async handlers are frozen.
Impact
- Real-time transcription latency spikes for all users when any single webhook endpoint is slow
- Audio byte streaming can block the event loop for up to 15 seconds per call
- Under load with multiple webhook-enabled users, this compounds into cascading stalls
Additionally found 4 more sync-in-async calls in backend/routers/auth.py and backend/routers/oauth.py.
Fix
Wrap sync requests calls with asyncio.to_thread() to offload them to a thread pool, keeping the event loop free:
response = await asyncio.to_thread(
requests.post, webhook_url, json=payload, headers=headers, timeout=15
)Files Affected
backend/utils/webhooks.py(critical — hot path)backend/routers/auth.py(lower priority — one-time auth flows)backend/routers/oauth.py(lower priority — one-time auth flows)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
backendBackend Task (python)Backend Task (python)bugSomething isn't workingSomething isn't workingperformance