Skip to content

close(sizeQueue.ch) called before <-done causing guaranteed send on closed channel panic #7778

@aashu2006

Description

@aashu2006

User Request

Type: bug
Target: Console Application
Submitted by: @aashu2006
Console Request ID: 0381abe7-6c94-438f-b832-5899b6620be1

Description

What happened:
In pkg/api/handlers/exec.go:506, close(sizeQueue.ch) is called at line 506 but <-done (which waits for the read goroutine to exit) is at line 511. The read goroutine can still be executing the case sizeQueue.ch <- remotecommand.TerminalSize{...} select arm at line 481 when the channel is already closed. This is a guaranteed runtime panic whenever a resize or stdin message arrives in the window between lines 506 and 511.

What I expected:
close(sizeQueue.ch) should be moved to after <-done so the read goroutine has fully exited before the channel is closed.

Steps to reproduce:

  1. Start an exec session
  2. Send a terminal resize message at the same time the exec stream ends
  3. Observe a runtime panic from send on closed channel

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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions