Skip to content

DisconnectUser closes WebSocket connection directly without unregister channel causing double-close race #6584

@aashu2006

Description

@aashu2006

User Request

Type: bug
Target: Console Application
Submitted by: @aashu2006
Console Request ID: d1a18a87-352d-4daf-9bd0-df9adf221443

Description

What happened:
In pkg/api/handlers/websocket.go:192-204, DisconnectUser closes connections directly:

client.conn.WriteMessage(...)
client.conn.Close()  // closes conn directly

The HandleConnection reader loop subsequently gets an error and sends to h.unregister. Meanwhile the writer goroutine may attempt conn.WriteMessage after Close(). The connection is closed twice and the client's send channel may be closed twice, causing a panic.

What I expected:
DisconnectUser should send through the h.unregister channel to let the hub handle cleanup in a coordinated way, preventing double-close races.

Steps to reproduce:

  1. Trigger DisconnectUser while the WebSocket writer goroutine is active
  2. Observe a panic from double-close on the connection or send channel

This issue was automatically created from the KubeStellar Console.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-fix-requestedhelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/bugCategorizes issue or PR as related to a bug.triage/neededNeeds triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions