Skip to content

Go: stop RPC client logging expected errors#609

Open
chlowell wants to merge 2 commits intogithub:mainfrom
chlowell:go-closed-stdout
Open

Go: stop RPC client logging expected errors#609
chlowell wants to merge 2 commits intogithub:mainfrom
chlowell:go-closed-stdout

Conversation

@chlowell
Copy link
Contributor

You might see Error reading header: read |0: file already closed printed during client shutdown on Linux. This happens because copilot.Client kills the CLI subprocess and calls the RPC client's Stop method, which closes the subprocess's stdout. Meanwhile, the RPC client has a read loop blocked on a pipe connected to the subprocess's stdout. That loop breaks with an error: io.EOF if the process teardown wins the race, os.ErrClosed if the pipe close does. The comment anticipates this but the guard around printing the error expects only io.EOF. So, simple fix to avoid logging the expected error condition is to add os.ErrClosed to the guard.

Copilot AI review requested due to automatic review settings February 28, 2026 03:30
@chlowell chlowell requested a review from a team as a code owner February 28, 2026 03:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts Go’s internal JSON-RPC client shutdown behavior to avoid logging an expected “closed pipe/file already closed” read error during teardown, reducing noisy stderr output when copilot.Client stops the CLI subprocess.

Changes:

  • Add errors/os imports to support error classification.
  • Suppress logging for read-loop header errors when the underlying error is os.ErrClosed (in addition to io.EOF).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants