Skip to content

mcp_server.py: init_task.cancel() not awaited — pending-task destruction can amplify disconnect symptoms #61

Description

@brandwe

File: src/entrabot/mcp_server.py
Location: L3683-L3693 _run_stdio_with_write_stream shutdown
Category: bug
Priority: low

Description

On shutdown init_task.cancel() is called but never awaited. If _eager_init is mid-Graph-call when the host disconnects, the task is destroyed pending; this produces stderr warnings that AGENTS.md keeps visible (never redirect stderr to /dev/null), and can interact with the open dropout bug.

Suggested fix

init_task.cancel(); with contextlib.suppress(asyncio.CancelledError, Exception): await asyncio.wait_for(init_task, timeout=2) before _flush_chat_cursors.


Filed automatically by a thorough code-review pass over src/entrabot/ on 2026-06-13. Internal review id: #48.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions