Skip to content

[MEDIUM] WebSocket handling blocks the accept loop for the lifetime of a connection #129

Description

@Daliys

Problem

ServerLoop awaits ProcessWebSocket(context) inline, so one long-lived WebSocket connection prevents the listener from accepting new contexts.

Evidence

  • Editor/MCPServer.Networking.cs:100-104 waits for GetContextAsync() then calls await ProcessWebSocket(context) for WebSocket requests.
  • HTTP requests are dispatched with fire-and-forget Task.Run, but WebSocket requests are not.

Impact

A connected WebSocket client can starve concurrent HTTP JSON-RPC clients or new WebSocket connections because the accept loop does not continue until the WebSocket receive loop exits.

Suggested fix

Dispatch each WebSocket handler independently like HTTP requests, or reject additional connections explicitly while preserving the accept loop. Track/cancel spawned tasks during shutdown if needed.

Source report

Imported from audit report item: resource-leak (9) / Editor/MCPServer.Networking.cs:102.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageImported or reported issue awaiting owner reviewpriority: mediumImportant defect or workflow gap with workaroundsurface: networkingHTTP, WebSocket, listener, origin, or authentication surfacetype: concurrencyConcurrency, timeout, async, or shared-state issuetype: resource-leakProcess, stream, handle, or lifecycle leak/hang risk

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions