Skip to content

DisconnectUser calls conn.WriteMessage directly racing the writer goroutine causing concurrent write panic #7041

@aashu2006

Description

@aashu2006

User Request

Type: bug
Target: Console Application
Submitted by: @aashu2006
Console Request ID: 5a266a3f-83cb-4c6b-beb2-30b118a45dc0

Description

What happened:
In pkg/api/handlers/websocket.go:244-246, DisconnectUser calls client.conn.WriteMessage directly while the writer goroutine at line 454 also writes to the same connection. gorilla/websocket explicitly states connections support only one concurrent writer. This race can cause a panic or corrupt WebSocket frames.

What I expected:
DisconnectUser should send a sentinel value through client.send channel so the writer goroutine sends the close frame itself, maintaining single-writer semantics.

Steps to reproduce:

  1. Run with -race flag
  2. Log out a user with an active WebSocket connection while messages are being sent
  3. Observe race detector flag on concurrent conn.WriteMessage calls

This issue was automatically created from the KubeStellar Console.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-fix-requestedai-processingAI is currently processing this issuekind/bugCategorizes issue or PR as related to a bug.triage/acceptedIndicates an issue or PR is ready to be actively worked on.triage/neededNeeds triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions