Skip to content

[CRIT-02] Synchronous Blocking I/O inside Async Event Loop Handler #39

Description

@sheepdestroyer

Location

router/main.py (inside get_dashboard endpoint, line 2180)

Problem Description

The /dashboard endpoint calls get_goose_sessions() synchronously. Because get_goose_sessions performs blocking disk reading operations against the SQLite database (sessions.db), it halts the entire asyncio event loop thread. Under load, this creates critical request-routing latency spikes for other endpoints since the single event loop thread is blocked.

Fix Overview

Offload the synchronous SQLite database interaction to a worker thread using asyncio.to_thread.

Proposed Implementation Steps

  1. Open router/main.py.
  2. Find get_dashboard endpoint.
  3. Locate goose_sessions = get_goose_sessions() (around line 2180).
  4. Change it to: goose_sessions = await asyncio.to_thread(get_goose_sessions).

Code Example / Diff

@@ -2179,3 +2179,3 @@
     # 2. Query Goose Sessions SQLite DB
-    goose_sessions = get_goose_sessions()
+    goose_sessions = await asyncio.to_thread(get_goose_sessions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjulesIssues for Jules

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions