Skip to content

Conversation

@rcdailey
Copy link
Contributor

Fixes the java.io.IOException: Stream closed exception that occurs when the CSharpier process fails to start in the Rider plugin.

Problem

The onExit handler was attempting to read from the error stream after the process had exited, but streams are automatically closed when a process terminates.

Solution

Read stderr continuously in a background thread during the process lifetime and capture output to a StringBuilder. The onExit handler then references the captured output instead of trying to read from the closed stream.

Approach

This follows the pattern used in JetBrains' own code (ForkedByModuleSplitter) for handling process streams safely, which uses separate named threads to read stdout and stderr while the process is running.

rcdailey and others added 2 commits November 26, 2025 10:35
The onExit handler was attempting to read from the error stream after
the process had exited, but the stream is automatically closed when
the process terminates. This caused java.io.IOException: Stream closed.

Now read stderr continuously in a background thread during process
lifetime and reference the captured output in the onExit handler.

This follows the pattern used in JetBrains' own code (ForkedByModuleSplitter)
for handling process streams safely.
Copy link
Owner

@belav belav left a comment

Choose a reason for hiding this comment

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

LGTM! I'll get a release out with this change shortly.

@belav belav merged commit afeb561 into belav:main Dec 5, 2025
7 checks passed
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