Skip to content

Eliminate sync-over-async in GitHub issue reporter #1802

Description

@Widthdom

Summary

SuggestionStore invokes GitHubIssueReporter.TryCreateIssueAsync(r, version).GetAwaiter().GetResult() (McpToolHandlers.cs:1933) inside a synchronous lambda callback. The HTTP call to the GitHub API blocks the calling thread for the round-trip duration, and any exception bubbles as an AggregateException rather than the original cause. In the MCP server context, this can block one of the limited stdio handler threads on a multi-second network call, stalling other unrelated tool requests.

Where

  • src/CodeIndex/Mcp/McpToolHandlers.cs:1933 (TryCreateIssueAsync sync wait)

Suggested approach

(1) Refactor the surrounding lambda to be async so the call becomes await GitHubIssueReporter.TryCreateIssueAsync(r, version) with ConfigureAwait(false). (2) For exception handling, catch the original HttpRequestException / OperationCanceledException directly rather than unwrapping AggregateException. (3) If the suggestion submit must remain fire-and-forget for UX reasons, dispatch via Task.Run(async () => ...) with a try/catch that logs failures, never blocks. (4) Add a regression test that mocks a slow GitHub response and asserts the MCP server continues servicing other requests during the wait. (5) Cross-link with #1418 (CancellationToken propagation) so a client cancel during the submit aborts the HTTP call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions