Skip to content

Exec reader goroutine not joined before HandleExec returns causing unordered exit message write #7048

@aashu2006

Description

@aashu2006

User Request

Type: bug
Target: Console Application
Submitted by: @aashu2006
Console Request ID: 8e838c8b-8903-4d72-bebd-4306dc6c0bf2

Description

What happened:
In pkg/api/handlers/exec.go:451-519, after StreamWithContext returns, HandleExec writes the exit message and returns without waiting for the reader goroutine to finish via <-done. The reader goroutine's cleanup (close(stdinCh), execCancel()) happens asynchronously after the handler returns. The exit message write and the reader's next ReadMessage call have no ordering guarantee.

What I expected:
<-done should be awaited before writing the exit message to ensure the reader goroutine has exited and cleanup is ordered correctly.

Steps to reproduce:

  1. Run an exec session and end it
  2. Observe the exit message is written while the reader goroutine may still be active
  3. Observe cleanup ordering issues in the reader goroutine

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